/* This program generates an non-fatal internal JIT error on JDK 1.1.6! * Sun was notified 8/20/99 so don't bother reporting it. This error has disappeared in 1.1.8 and 1.3 */ /** Test Timing Jitter * @author Phil Burk and Nick Didkovsky */ /* * (C) 1997 Phil Burk and Nick Didkovsky, All Rights Reserved * JMSL is based upon HMSL (C) Phil Burk, Larry Polansky and David Rosenboom. */ package jmsltestsuite; import java.awt.Frame; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class TestJitter { static final int NUM_LOOPS = 20; public static void main(String args[]) { Frame f = new Frame("TestJitter"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setSize(500, 100); f.setVisible(true); System.out.println("/* This program generates an non-fatal internal JIT error on JDK 1.1.6! "); System.out.println(" * Sun was notified 8/20/99 so don't bother reporting it."); System.out.println(" This error has disappeared in 1.1.8 and 1.3"); long[] times = new long[NUM_LOOPS]; long[] curTimes = new long[NUM_LOOPS]; long lastTime, nextTime, currentTime, sleepFor; Thread.currentThread().setPriority(Thread.MAX_PRIORITY); lastTime = System.currentTimeMillis(); for (int i = 0; i < NUM_LOOPS; i++) { nextTime = lastTime + 1000; while (true) { currentTime = System.currentTimeMillis(); sleepFor = nextTime - currentTime; if (sleepFor <= 0) break; try { Thread.sleep(sleepFor); } catch (InterruptedException e) { System.err.println("Err = " + e); } } lastTime = nextTime; times[i] = System.currentTimeMillis(); curTimes[i] = currentTime; } for (int i = 1; i < NUM_LOOPS; i++) { System.out.println("diff = " + (times[i] - times[i - 1]) + "cur diff = " + (curTimes[i] - curTimes[i - 1])); } } }