Created
August 15, 2012 21:57
-
-
Save 2sbsbsb/3364047 to your computer and use it in GitHub Desktop.
BTrace script for profiling method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* BTrace Script Template */ | |
import com.sun.btrace.annotations.*; | |
import static com.sun.btrace.BTraceUtils.*; | |
import com.sun.btrace.Profiler; | |
@BTrace | |
public class TracingScript { | |
// Initiate the profiler instance | |
public static Profiler p = com.sun.btrace.BTraceUtils.Profiling.newProfiler(); | |
@OnMethod(clazz="com.test.TestRunner", method="commonMethod", location=@Location(value=Kind.ENTRY)) | |
public static void onEnter(@ProbeMethodName(fqn=true) String methodFqn){ | |
Profiling.recordEntry(p, methodFqn); | |
} | |
@OnMethod(clazz="com.test.TestRunner", method="commonMethod", location=@Location(value=Kind.RETURN)) | |
public static void onExit(@Duration long dur, @ProbeMethodName(fqn=true) String methodFqn) { | |
Profiling.recordExit(p, methodFqn,dur); | |
} | |
// Print this method on any user event | |
@OnEvent() | |
public static void showDataEvent() { | |
Profiling.printSnapshot("User event", p); | |
} | |
// Print one min is elapsed | |
@OnTimer(36000) | |
public static void showDataTimer() { | |
Profiling.printSnapshot("",p); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment