ccs.utils
Class Profiler

java.lang.Object
  extended by ccs.utils.Profiler

public class Profiler
extends java.lang.Object

A Profiler provides basic support for profiling an application - seeing how long various bits of a process take to perform. It's no substitute for a full profiling architecture, and you do need to take it out before deploying the app (it slows things down a bit), but it can be useful where a process is severely underperforming. NB. No I18N.

MT-UNSAFE. Objects must be confined to the same thread. In a MT app, the vagiaries of thread scheduling may foul up your results - the profiler doesn't stop its clock when the thread is timesliced out.


Constructor Summary
Profiler()
          Construct a new Profiler.
 
Method Summary
 void mark(java.lang.String marker)
          Add a "waypoint".
 void report()
          Report the profile to System.out with a default prefix.
 void report(java.io.PrintStream ps, java.lang.String prefix)
          Report the profile to the supplied PrintStream (typically System.out).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Profiler

public Profiler()
Construct a new Profiler.

Method Detail

mark

public void mark(java.lang.String marker)
Add a "waypoint". A waypoint is a point in time which you give a name to. The output of the profiler will be the list of waypoints, and the time (relative to the time the Profiler was constructed) at which each waypoint was reached.

Parameters:
marker - The name of the waypoint, for reporting purposes. If null, a waypoint will be marked as normal, but will come out as a blank line on the final report.

report

public void report()
Report the profile to System.out with a default prefix.


report

public void report(java.io.PrintStream ps,
                   java.lang.String prefix)
Report the profile to the supplied PrintStream (typically System.out).

Parameters:
ps - The PrintStream to report to.
prefix - The string to prefix every line of the report with.