Skip to content

TimerLog

vtk-examples/Java/Utilities/TimerLog

Description

Example to Demonstrate Timer support and logging.

The object [vtkTimerLog](https://www.vtk.org/doc/nightly/html/classvtkTimerLog.html#details) 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)

Question

If you have a question about this example, please use the VTK Discourse Forum

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);         
  }
}