Alex Rivera | Logout

Is System.currentTimeMillis() the best measure of time performance in Java?

Asked 2009-07-02T09:13:13.730
17

Is System.currentTimeMillis() the best measure of time performance in Java? Are there any gotcha's when using this to compare the time before action is taken to the time after the action is taken? Is there a better alternative?

Edit
Report

1 Answer

2

besides System.nanoTime(), JMX is probably the best viable option:

java.lang.management.ManagementFactory.getThreadMXBean()

you can query current thread cpu time (measured in nano seconds but not with nano seconds precision, as for System.nanoTime())

answered 2009-07-02T09:20:47.040

Your Answer