com.sun.btrace
Class BTraceUtils.Profiling

java.lang.Object
  extended by com.sun.btrace.BTraceUtils.Profiling
Enclosing class:
BTraceUtils

public static class BTraceUtils.Profiling
extends java.lang.Object

Profiling support. It is a highly specialized aggregation (therefore not included in the generic aggregations support) which is able to calculate clean self time spent in hierarchically called methods (or bigger parts of code)


Constructor Summary
BTraceUtils.Profiling()
           
 
Method Summary
static Profiler newProfiler()
          Creates a new Profiler instance
static Profiler newProfiler(int expectedBlockCnt)
          Creates a new Profiler instance with the specified expected count of the distinct methods to be recorded.
static void printSnapshot(java.lang.String name, Profiler profiler)
           
static void printSnapshot(java.lang.String name, Profiler profiler, java.lang.String format)
           
static void recordEntry(Profiler profiler, java.lang.String blockName)
          Records the entry to a particular code block
static void recordExit(Profiler profiler, java.lang.String blockName, long duration)
          Records the exit out of a particular code block
static void reset(Profiler profiler)
           
static Profiler.Snapshot snapshot(Profiler profiler)
          Creates a new snapshot of the profiling metrics collected sofar
static Profiler.Snapshot snapshotAndReset(Profiler profiler)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BTraceUtils.Profiling

public BTraceUtils.Profiling()
Method Detail

newProfiler

public static Profiler newProfiler()
Creates a new Profiler instance

Returns:
A new Profiler instance

newProfiler

public static Profiler newProfiler(int expectedBlockCnt)
Creates a new Profiler instance with the specified expected count of the distinct methods to be recorded.

Parameters:
expectedBlockCnt - The expected count of the distinct blocks to be recorded.
Returns:
Returns a new Profiler instance

recordEntry

public static void recordEntry(Profiler profiler,
                               java.lang.String blockName)
Records the entry to a particular code block

Parameters:
profiler - The Profiler instance to use
blockName - The block identifier

recordExit

public static void recordExit(Profiler profiler,
                              java.lang.String blockName,
                              long duration)
Records the exit out of a particular code block

Parameters:
profiler - The Profiler instance to use
blockName - The block identifier
duration - The time spent in the mentioned block

snapshot

public static Profiler.Snapshot snapshot(Profiler profiler)
Creates a new snapshot of the profiling metrics collected sofar

Parameters:
profiler - The Profiler instance to use
Returns:
Returns an immutable snapshot of the profiling metrics in the form of a map where the key is the block name and the value is a map of metrics names and the appropriate values
The supported metrics names are: "selfTime", "wallTime" and "invocations"

snapshotAndReset

public static Profiler.Snapshot snapshotAndReset(Profiler profiler)

reset

public static void reset(Profiler profiler)

printSnapshot

public static void printSnapshot(java.lang.String name,
                                 Profiler profiler)

printSnapshot

public static void printSnapshot(java.lang.String name,
                                 Profiler profiler,
                                 java.lang.String format)