blob: 56ececd8dd2cfdc5747120210c4a4aa7added129 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
// ----------------------------------------------------------------------------
|