TimerLog

VTKExamples/Java/Utilities/TimerLog

Description

Example to Demonstrate Timer support and logging.

The object vtkTimerLog` contains walltime and cputime measurements associated with a given event.

These results can be later analyzed when "dumping out" the table. In addition, vtkTimerLog allows the user to simply get the current time, and to start/stop a simple timer that is separate from the timing table logging.

Other Languages

See (Cxx)

Code

TimerLog.java

import vtk.vtkNativeLibrary;
import vtk.vtkTimerLog;

public class TimerLog 
{
  //-----------------------------------------------------------------
  // Load VTK library and print which library was not properly loaded
  static 
  {
    if (!vtkNativeLibrary.LoadAllNativeLibraries()) 
    {
      for (vtkNativeLibrary lib : vtkNativeLibrary.values()) 
      {
        if (!lib.IsLoaded()) 
        {
          System.out.println(lib.GetLibraryName() + " not loaded");
        }
      }
    }
    vtkNativeLibrary.DisableOutputWindow(null);
  }
  //-----------------------------------------------------------------

  public static void main(String s[]) 
  {
    vtkTimerLog TimerLog = new vtkTimerLog();

    System.out.println("Current Time:" + TimerLog.GetUniversalTime());
    TimerLog.MarkEvent("File Opened");
    TimerLog.MarkEvent("Did Somthing");
    System.out.println("Timer Log:" + TimerLog);         
  }
}