Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: What is the unit of the difference of two System.currentTimeMillis?

Tags:

java

What is the unit of the difference of two System.currentTimeMillis ?

start = System.currentTimeMillis();
longoperation();
elapsedTime = System.currentTimeMillis() - start;

What is the unit of elapsed time here. It doesn't look like milliseconds. Is the above code segment the right way to find the time taken to execute longoperation()?

like image 671
softwarematter Avatar asked Dec 10 '25 22:12

softwarematter


1 Answers

Yes, it is in milliseconds. Bear in mind that the difference is not absolutely correct and may vary.

like image 191
Boris Pavlović Avatar answered Dec 12 '25 13:12

Boris Pavlović



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!