Questions tagged [nanotime]

Anything related to programming languages functions (or other similar facilities) allowing the retrieval of the current time with a resolution in the nanoseconds range.

Anything related to programming languages functions (or other similar facilities) allowing the retrieval of the current time with a resolution in the nanoseconds (ns) range.

146 questions
1
vote
1 answer

Measuring the duration of a selection sort for-loop

Apologies upfront, this is my first time posting, and I'm new to programming. Right now I am writing a program that times how long it takes for a selective sort algorithm to finish sorting. The code takes user input for how many integers are in the…
Wil
  • 131
  • 1
  • 2
  • 9
1
vote
2 answers

system can not handle events fired on nanoseconds, why?

I really seek a logical explanation regarding the following. I have a timed task static TimerTask timedTask = new TimerTask() { @Override public void run() { // TODO Auto-generated method stub System.out.println("timed…
Amrmsmb
  • 1
  • 27
  • 104
  • 226
1
vote
2 answers

1000000000 nanoseconds do not appear to equal a second

I am creating some magic spells, and obviously I want a delay between each usage. Now According to google, there are 1000000000 nanoseconds in a second. However, the magic spell is recharging after less than two seconds. @EventHandler public void…
Joehot200
  • 1,070
  • 15
  • 44
1
vote
1 answer

nanoTime & currentMilliSeconds used in a loop in java

I am trying to measure the speed of different encryption algorithms. I thought I would start of with logging the current time (either nano or milli) then run the actions needed, once done, grab the time and and compare. It all worked for one…
colobusgem
  • 473
  • 1
  • 4
  • 18
1
vote
1 answer

Finding Nano Time in Windows using PHP

I would like to create a unique id in php.I used uniqid() but microtime is not helping because the function is inside a loop and a set of consecutive results are exactly the same!! So i am wondering if i can use nano time.In linux it possible…
Nidhin David
  • 2,426
  • 3
  • 31
  • 45
1
vote
2 answers

Java: Using System.nanoTime() sorting function taking too long to execute

I am trying to get the total elapsed time for various sort methods at differing array sizes. I am able to get the elapsed time for size = 100, 1000, 10000, and 100000, but when I try 1000000 it just keeps running without giving the result(I assume…
lchristina26
  • 205
  • 5
  • 20
1
vote
1 answer

nanosecond Measurement in arduino using clock_gettime

I making a Localization project Using Arduino and Xbee Zg where i need to measure time in nano second resolution im using arduino due board with 84 Mhz clock and arduino 1.5.2 IDE im trying to use clock_gettime function i already included time.h but…
PrinceOfEgy
  • 21
  • 2
  • 5
1
vote
1 answer

Why aren't results closer together? (I'm only doing one trial)

I wrote a program to time certain square root algorithms import java.math.BigDecimal; public class ScienceFairTwo { public static final BigDecimal TWO = new BigDecimal(2); public static final BigDecimal SQRT_TWO = new…
1
vote
2 answers

Multithreading with Java nanoTime

I am currently programming a multithreaded program with Java. At some points different threads log their actions and I'm using nanoTime for this. Every thread has it's own log file and at the end I merge them and sort them based on their time…
insumity
  • 5,311
  • 8
  • 36
  • 64
1
vote
4 answers

Java System.nanoTime() vs System.currentTimeMillis(). Why do they have different outputs?

Given the following Java code: class Tester { public static void main(String[] args) { System.out.println((System.nanoTime()/1000)); System.out.println(System.currentTimeMillis()); } } It gave an output…
Abel Callejo
  • 13,779
  • 10
  • 69
  • 84
1
vote
2 answers

Android - Measuring the time between opening an activity via intent and when results are received

I have a simple application that opens the Barcode Scanner App by ZXing. Now, I want to know how much time it takes for a scan to accomplish. Basically, the time when the intent was started up to the time that the result is obtained. Now, I know…
Razgriz
  • 7,179
  • 17
  • 78
  • 150
1
vote
2 answers

strace java applet

I'm trying to strace a java applet, and strace doesn't seem to be working. I'm calling the following function. public static void testSTrace(){ long c = 0; for (int i = 0; i < 1000; i++){ long start = System.nanoTime(); …
Ethan Heilman
  • 16,347
  • 11
  • 61
  • 88
0
votes
2 answers

Java System.nanoTime elapsed average time keeps getting smaller

This is not the first time I've had problems with clock times in a programming language. Basically I'm measuring how fast a function is running by calling it in a while loop. Problem is that for some reason the elapsed time keeps getting shorter the…
Thirlan
  • 712
  • 1
  • 8
  • 26
0
votes
0 answers

Print non sequential array

I have created a method for generating an array of random numbers between 1 to 100000. How can I print result for 1000, 5000, 10000 and 50000 random integers. //main method public static void main (String[] args) { int[] array; long…
0
votes
1 answer

How to get nano seconds from milisecond since epoch?

const time = '2022-01-13T18:40:44.748903Z'; const date = new Date(time); const millisecondsSinceEpoch = date.getTime(); const seconds = Math.floor(millisecondsSinceEpoch / 1000); how to get nano seconds in Javascript?
icelemon
  • 827
  • 2
  • 11
  • 23