Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check how many milliseconds passed in some event(java) [duplicate]

Possible Duplicate:
Calculating time difference in Milliseconds

How i can check how many milliseconds passed in some event in java? For example:

Want to start timer here<<
   function doSomething()
   .
   .
Want to finish timer here<<

I want to check how many milliseconds passed. Is there a way to do it?

like image 553
Farseer Avatar asked Nov 30 '22 04:11

Farseer


1 Answers

System.nanoTime()

and compare the start value to end value. Here is the doc.

Returns the current value of the most precise available system timer, in nanoseconds.

like image 88
NimChimpsky Avatar answered Dec 02 '22 17:12

NimChimpsky