com.sun.btrace
Class Profiler

java.lang.Object
  extended by com.sun.btrace.Profiler

public abstract class Profiler
extends java.lang.Object

Profiler is a highly specialized aggregation-like data collector optimized for high-speed collection of the application execution call tree data.

It is exposable as MBean via Property annotation

Since:
1.2
Author:
Jaroslav Bachorik

Nested Class Summary
static interface Profiler.MBeanValueProvider
          Helper interface to make accessing a Profiler as an MBean type safe.
static class Profiler.Record
          Record represents an atomic unit in the application execution call tree
static class Profiler.Snapshot
          Snapshot is an immutable image of the current profiling data collected by the Profiler

It is created by calling snapshot() method
 
Field Summary
 long START_TIME
          This property exposes the time of creating this particular Profiler instance.
 
Constructor Summary
Profiler()
          Creates a new Profiler instance
 
Method Summary
abstract  void recordEntry(java.lang.String blockName)
          Records the event of entering an execution unit (eg.
abstract  void recordExit(java.lang.String blockName, long duration)
          Records the event of exiting an execution unit (eg.
abstract  void reset()
          Resets all the collected data
 Profiler.Snapshot snapshot()
          Creates an immutable snapshot of the collected profiling data
abstract  Profiler.Snapshot snapshot(boolean reset)
          Creates an immutable snapshot of the collected profiling data.
Makes it possible to reset the profiler after creating the snapshot, eventually
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

START_TIME

public final long START_TIME
This property exposes the time of creating this particular Profiler instance.
The unit is milliseconds.

Constructor Detail

Profiler

public Profiler()
Creates a new Profiler instance

Method Detail

recordEntry

public abstract void recordEntry(java.lang.String blockName)
Records the event of entering an execution unit (eg. method)
Must be paired with a call to recordExit(java.lang.String, long) with the same blockName, eventually

Parameters:
blockName - The execution unit identifier (eg. method FQN)

recordExit

public abstract void recordExit(java.lang.String blockName,
                                long duration)
Records the event of exiting an execution unit (eg. method)
Must be preceded by a call to recordEntry(java.lang.String) with the same blockName

Parameters:
blockName - The execution unit identifier (eg. method FQN)
duration - Invocation duration in nanoseconds

snapshot

public final Profiler.Snapshot snapshot()
Creates an immutable snapshot of the collected profiling data

Returns:
Returns the immutable Profiler.Snapshot instance

snapshot

public abstract Profiler.Snapshot snapshot(boolean reset)
Creates an immutable snapshot of the collected profiling data.
Makes it possible to reset the profiler after creating the snapshot, eventually

Parameters:
reset - Signals the profiler to perform reset right after getting the snapshot (in an atomic transaction)
Returns:
Returns the immutable Profiler.Snapshot instance

reset

public abstract void reset()
Resets all the collected data