diff options
author | Stiver <stiver.mail@gmail.com> | 2014-03-04 15:13:11 +0100 |
---|---|---|
committer | Stiver <stiver.mail@gmail.com> | 2014-03-04 15:13:11 +0100 |
commit | e2d0f5d9c38561d67f23754c00addb4a3547efb2 (patch) | |
tree | 1832f16037c086b48266b8566aecc61f45f4e5f1 /timer/SystemTimerResolution.java | |
download | fernflower-e2d0f5d9c38561d67f23754c00addb4a3547efb2.tar fernflower-e2d0f5d9c38561d67f23754c00addb4a3547efb2.tar.gz fernflower-e2d0f5d9c38561d67f23754c00addb4a3547efb2.tar.lz fernflower-e2d0f5d9c38561d67f23754c00addb4a3547efb2.tar.xz fernflower-e2d0f5d9c38561d67f23754c00addb4a3547efb2.zip |
initial commit
Diffstat (limited to 'timer/SystemTimerResolution.java')
-rw-r--r-- | timer/SystemTimerResolution.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/timer/SystemTimerResolution.java b/timer/SystemTimerResolution.java new file mode 100644 index 0000000..56ececd --- /dev/null +++ b/timer/SystemTimerResolution.java @@ -0,0 +1,31 @@ +// ---------------------------------------------------------------------------- +/** + * A simple class to see what the Java system timer resolution is on your + * system. + * + * @author (C) <a href="mailto:vroubtsov@illinoisalumni.org">Vlad Roubtsov</a>, 2002 + */ +public class SystemTimerResolution +{ + // public: ................................................................ + + public static void main (final String [] args) + { + // JIT/hotspot warmup: + for (int r = 0; r < 3000; ++ r) System.currentTimeMillis (); + + long time = System.currentTimeMillis (), time_prev = time; + + for (int i = 0; i < 5; ++ i) + { + // busy wait until system time changes: + while (time == time_prev) + time = System.currentTimeMillis (); + + System.out.println ("delta = " + (time - time_prev) + " ms"); + time_prev = time; + } + } + +} // end of class +// ---------------------------------------------------------------------------- |