java System.nanoTime is really slow. Is it possible to implement a high performance java profiler?
Posted
by willpowerforever
on Stack Overflow
See other posts from Stack Overflow
or by willpowerforever
Published on 2010-03-19T09:37:12Z
Indexed on
2010/03/19
9:41 UTC
Read the original article
Hit count: 288
java
I did a test and found the overhead of a function call to System.nanoTime() is at least 500 ns on my machine.
Seemed that it is very hard to have a high performance java profiler. For enterprise software, suppose a function takes about 350 seconds and has 12,500,000,000 times of method calls. Therefore, the number of calls to System.nanoTime() is: 12,500,000,000 * 2 = 25,000,000,000 (one for start timestamp, one for end timestamp) And the overhead of System.nanoTime in total is: 500 ns * 25,000,000,000 = 500 * 25000 s = 12500000s.
Note: all data from real case.
Any better way to acquire the timestamp?
© Stack Overflow or respective owner