org.openptk.util
Class Timer

java.lang.Object
  extended by org.openptk.util.Timer

public class Timer
extends java.lang.Object

Singleton class which will hold timers that can be used by any calling class to time start/stop timers and report on timings


Method Summary
static void main(java.lang.String[] argv)
           
static long startTimer(java.lang.String timerName)
          StartTimer will capture the time this method is called and store it in a timer named by the passed argument timerName.
static long stopTimer(java.lang.String timerName)
          StopTimer will capture the time this method is called and return the elapsed time in ms since the corresponding StartTimer was called for that timerName.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

main

public static void main(java.lang.String[] argv)

startTimer

public static long startTimer(java.lang.String timerName)
StartTimer will capture the time this method is called and store it in a timer named by the passed argument timerName.

Multiple successive startTimer methods can be called. Each timer is pushed onto a stack that will be popped off only after a stopTimer method is called.

Note: This is a static factory method that will create the one and only singleton instance if it hasn't been created yet.

Parameters:
timerName - String of name of timer
Returns:
long Current time, in ms, of this timer

stopTimer

public static long stopTimer(java.lang.String timerName)
StopTimer will capture the time this method is called and return the elapsed time in ms since the corresponding StartTimer was called for that timerName. If the timer wasn't started, then the resulting time returned will be -1.

Note: This is a static factory method that will create the one and only singleton instance if it hasn't been created yet.

Parameters:
timerName - String of name of timer
Returns:
long Elapsed time, in ms, since last startTimer was called


View/submit a bug or feature

For further API reference and developer documentation, see www.openptk.org. That documentation contains more detailed, developer-targeted descriptions, definitions of terms, workarounds, and working code examples.

Copyright (C) 2008-2012, Project OpenPTK. All Rights Reserved