Extension SDK

oracle.ide.util
Class StopWatch

java.lang.Object
  extended byoracle.ide.util.StopWatch

public final class StopWatch
extends java.lang.Object

The StopWatch class can be used to time specific events. An event is identified by a string name and when set to true in a properties file the StopWatch is turned on. For example, setting "stopwatch.myEventName = true" in the sw.properties file allows the StopWatch class to measure the time in milliseconds between calls to StopWatch.start( eventOn ) and StopWatch.stop(). The sw.properties file needs to be located in the directory from where the application is run. In your code you should call StopWatch.findEvent() only once and store the returned value in order to pass it on to the StopWatch.start( eventOn ). For example, let's assume you are debuggig multiple methods of a class, the you would use the StopWatch class as follows: import oracle.ide.util.StopWatch; public class MyClass { private static final boolean eventOn = StopWatch.findEvent( "myclass", "Timing MyClass" ); public int method1() { final long start = StopWatch.start( eventOn ); // The code you want to time StopWatch.stop( eventOn, start, "method1 took:" ); } } To turn your event on you need to add the following line to the sw.properties file: stopwatch.myclass = true


Field Summary
static boolean on
          Allows users to check whether the StopWatch is turned on.
 
Constructor Summary
StopWatch()
           
 
Method Summary
static boolean findEvent(java.lang.String event, java.lang.String msg)
          Find out if the specified event has been turned on in the sw.properties file.
static void logMsg(boolean go, java.lang.String msg)
          Print the specified message.
static long start(boolean go)
          Start timing.
static long stop(boolean go, long start, java.lang.String msg)
          Stop timing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

on

public static final boolean on
Allows users to check whether the StopWatch is turned on. The stopwatch is on when the sw.properties file exists in the current directory.

Constructor Detail

StopWatch

public StopWatch()
Method Detail

logMsg

public static void logMsg(boolean go,
                          java.lang.String msg)
Print the specified message.


findEvent

public static boolean findEvent(java.lang.String event,
                                java.lang.String msg)
Find out if the specified event has been turned on in the sw.properties file. If it has, this method prints the specified msg and returns true.


start

public static long start(boolean go)
Start timing. The specified argument go should be the returned value from findEvent. The return value is the current time in milliseconds.


stop

public static long stop(boolean go,
                        long start,
                        java.lang.String msg)
Stop timing. The specified argument go should be the returned value from findEvent. The start parameter is the returned value from the start method. The last parameter is the message to prepend to the reported duration of the event. The return value is the duration time in milliseconds.


Extension SDK

 

Copyright ©1997, 2003, Oracle. All rights reserved.