Measure elapsed time in Nanoseconds with Java

by Hendrik Will. 0 Comments

For my recent experimental gaming project I wanted to measure the overall elapsed time since the beginning of a game.
In my main class I added a startup variable of type long which contains the current time in nanoseconds. At the end of a game call the function stopWatch(startup); to get the elapsed time in seconds.

Example:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>