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
11
votes
4 answers

Why is my System.nanoTime() broken?

Myself and another developer on my time recently moved from a Core 2 Duo machine at work to a new Core 2 Quad 9505; both running Windows XP SP3 32-bit with JDK 1.6.0_18. Upon doing so, a couple of our automated unit tests for some…
Chad
  • 341
  • 6
  • 18
11
votes
2 answers

What does division by 1e9d mean?

This is the snippet: String myTime = someTime / 1e9d + ","; someTime is derived by using System.nanoTime(). What does 1e9d do here?
user1071840
  • 3,522
  • 9
  • 48
  • 74
10
votes
1 answer

Different values for nano time in different sensor data. How to figure them out?

Since the latest Android update (v. 8), I realized a very strange behavior while trying to read sensors. More specifically, I am speaking about WiFi and Cell Towers. Here are two examples: While I read WiFi access point information data and try to…
Moh
  • 1,887
  • 3
  • 18
  • 29
9
votes
1 answer

Centos 7, 400x slower for System.nanoTime than windows

I have seen and read posts on why System.nanoTime() is slower on some OSes than others, however I have never seen anything to explain the difference I am seeing now. Using JMH, I am running this benchmark. (Note: it uses System.nanoTime() as…
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
8
votes
3 answers

Java System.nanoTime() huge difference in elapsed time

I'm in and android widget and checking elapsed time between two calls of System.nanoTime() and the number is huge. How do you measure elapsed time with this? it should be a fraaction of a second and instead its much more. Thanks
Androider
  • 21,125
  • 36
  • 99
  • 158
8
votes
2 answers

Why the first call to constructor takes 10 times more time than other ones?

class testx { public testx() { long startTime = System.nanoTime(); System.out.println((System.nanoTime() - startTime)); } public static void main(String args[]) { new testx(); new testx(); new testx(); } } I…
good_evening
  • 21,085
  • 65
  • 193
  • 298
7
votes
2 answers

System.nanoTime vs System.currentTimeMillis

According to its documentation, System.nanoTime returns nanoseconds since some fixed but arbitrary origin time. However, on all x64 machines I tried the code below, there were time jumps, moving that fixed origin time around. There may be some flaw…
Ralf H
  • 1,392
  • 1
  • 9
  • 17
6
votes
3 answers

Java randomizing String

I'm trying to generate meaningless words without using any Random() functions. I figured out that i can use current clock or mouse coordinate. And i picked to use current clock. Here is the code i wrote. private final char[] charray =…
Jarnsida
  • 63
  • 7
6
votes
1 answer

Can nanoTime work across threads

I have a thread which pushes data into a queue and another thread which reads data from queue and processes it. I would like to check how long the data sits in the queue before getting processed. I added a time parameter (calculated using…
cppcoder
  • 22,227
  • 6
  • 56
  • 81
6
votes
2 answers

how correctly display nanotime to second conversion

I have a BFS algorithm to solve the 8-Puzzle, and one of the project requirements is to output the amount of time it takes to find the shallowest solution. I am using System.nanoTime() to keep track of the applications run time because it solves the…
chris edwards
  • 1,332
  • 4
  • 13
  • 31
5
votes
4 answers

Comparing System.nanoTime() values resulting from different machines

Is it correct to compare two values resulting from a call to System.nanoTime() on two different machines? I would say no because System.nanoTime() returns a nanosecond-precise time relative to some arbitrary point time by using the Time Stamp…
Laurent
  • 14,122
  • 13
  • 57
  • 89
5
votes
1 answer

JMeter's nanoThreadSleep Property - How do I use it?

I'm setting up a load testing solution, and as I've been reading through JMeter's docs, I see that you can set numerous properties for test plans. I've got tests already running just fine and producing results, graphs, etc., but as I tried to gain…
liltitus27
  • 1,670
  • 5
  • 29
  • 46
5
votes
5 answers

How to get system time in nano seconds in Perl?

I wanted to get system time in nano seconds in Perl. I tried Time::HiRes module and it's supporting only until micro seconds.
5
votes
3 answers

why is this simple C++ addition 6 times slower than the equivalent Java?

hello stackoverflow users, this is my first question asked, so if there are any errors in my way of expressing it, please point it out, thank you I wrote this simple calculation function in both Java and C++ Java: long start =…
shingekinolinus
  • 129
  • 1
  • 8
5
votes
1 answer

How can I receive the Hardware Timestamp of Audiorecord in Android?

I need to retrieve the timestamp of when the AudioRecord class does a read of a buffer. I need to keep track of the time in milliseconds. I have tried to add a timestamp retrieve after I read the buffer, however when I receive the next buffer, the…
David M
  • 51
  • 4
1
2
3
9 10