Fork Of

gist: 142054 by rhyolight A groovy template for Simpl...

Revisions

gist: 142635 Download_button fork
public
Public Clone URL: git://gist.github.com/142635.git
Embed All Files: show embed
Java #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.util.Map;
import static com.sun.btrace.BTraceUtils.*;
import com.sun.btrace.annotations.*;
 
@BTrace
public class ManyMethodTimerTemplate {
    @TLS private static Map<String, Long> startTimes = newHashMap();
 
<% targetClasses.eachWithIndex { className, classData, classIndex -> %>
<% classData.targetMethods.eachWithIndex { targetMethod, methodIndex -> %>
 
@OnMethod(clazz = "$className", method = "$targetMethod")
public static void start_${classIndex}_${methodIndex}() {
put(startTimes, "$className", timeMillis());
println(strcat(strcat(strcat(strcat(strcat("entered|", name(probeClass())), "|"), probeMethod()), "|"),
str(get(startTimes, "$className"))));
}
 
@OnMethod(clazz = "$className", method = "$targetMethod", location = @Location(where = Where.BEFORE, value = Kind.RETURN))
public static void end_${classIndex}_${methodIndex}() {
long endtime = timeMillis();
String duration = str(endtime - get(startTimes, "$className"));
println(strcat(strcat(strcat(strcat(strcat(strcat(strcat(strcat("completed|", name(probeClass())), "|"), probeMethod()),
"|"), str(endtime)), "|"), duration), "|"));
}
 
<% } %>
<% } %>
 
}