This Java tip shows how to use J3DTimer class in Java3D.

 import java.applet.Applet;
import java.awt.Panel;
import java.awt.TextArea;

import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.timer.J3DTimer;

public class TimerTest extends Applet {

  long[] ticks = new long[10];

  long[] sysTime = new long[ticks.length];

  public TimerTest() {
  }

  public void init() {
    Panel panel = new Panel();
    String header = new String(
        "              J3D Timer                System Timer\n");
    TextArea textArea = new TextArea(header, 12, 35,
        TextArea.SCROLLBARS_NONE);
    panel.add(textArea);
    this.add(panel);

    for (int i = 0; i < ticks.length; i++) {
      ticks[i] = J3DTimer.getValue();
      sysTime[i] = System.currentTimeMillis();
    }

    for (int i = 0; i < ticks.length; i++)
      //System.out.println("tick "+ticks[i]+" "+sysTime[i] );
      textArea.append("tick " + ticks[i] + "    " + sysTime[i] + "\n");
    //System.out.println("Resolution "+J3DTimer.getResolution() );
    textArea.append("Resolution " + J3DTimer.getResolution() + "\n");

  }

  public static void main(String args[]) {
    new MainFrame(new TimerTest(), 380, 256);
  }

}