此示例演示探针定义的一些最常用的部分。
在此示例中,每当调用探测方法时,探针都会对计数器加上 1。在第一次调用探测方法时,然后在每第 1000 次方法调用时,它都使用 System.out.println 来显示计数器值和导致计数器滚动计数的方法的名称。
在 Probekit 编辑器中将通过以下条目来定义此探针:
static public int entry_counter = 0;
if ((entry_counter % 1000) == 0) System.out.println("Counter value " + entry_counter + " at a call to " + _class + "." + _method); entry_counter++;