TimerRes.java

Download TimerRes.java

 1: // This program attempts to measure the system clock resolution.
 2: // On my Windows 10 PC (in 5/2021), I see 200-210 updates per second.
 3: //
 4: // Writeen 5/2021 by Wayne Pollock, Tampa Florida USA
 5: 
 6: public class TimerRes {
 7:     public static void main (String[] args) {
 8:         System.out.println( "Starting 60 second measurement..." );
 9:         long now = System.currentTimeMillis();
10:         long end = now + 60 * 1_000;  // One minute later
11:         long previous = now;
12:         int numOfTimeChanges = 0;
13:         while ( now <= end ) {
14:             if ( now != previous ) {
15:                 ++numOfTimeChanges;
16:                 previous = now;
17:             }
18:             now = System.currentTimeMillis();
19:         }
20:         System.out.printf( "Number of Times the clock updates per "
21:             + "second is %.2f%n", (numOfTimeChanges/60.0) );
22:     }
23: }