Timer
Variable Resolution Stopwatch
License: LGPL (license.txt)
API
Docs: Can be found here
Changelog:
Can be found here
Short Description:
The Deimos Timer allows seamless useage of the
millisecond timer or nanosecond timer, depending on what's available.
Long Description:
I needed a timer of some kind for The Deimos
Project. I wasn't happy with the results of using the millsecond
timer built into the java.lang.System class, but I wasn't happy with
the idea of being forced to use Java 1.5, either. This library is
the compromise. It allows you to use the same API to access time
data from either, or the platform specific sun.misc.Perf class.
For
more information, look at the API docs for StopWatch.
Here's the order of time source priority:
java.lang.System.nanoTime(), sun.misc.Perf, and
finally, java.lang.System.currentTimeMillis() if none of the others can
be found.
You also have the ability to plug in your own custom
TimeSource to StopWatch.
If you need to manually control the progression of
time in your application, try SteppingTimeSource.
Usage:
While the timer is intended to be used as a library,
it is also an application that will determine the granularity of your
system's best available timer and display it for you. This will
tell you how small of an increment of time the StopWatch can provide
(on
average). It will also test the timer library.
If you want to run the granularity test, just type
the following in a console window: "java -jar timer.jar". This can take a LONG time
for a system that can only use the millisecond system timer.
Hosting for this project generously
provided by: