Search code examples
javaprofilingbtrace

What time units are provided by BTrace when using @Duration annotation? Millis, micros or maybe nanos? Cannot find it in the documentation


Look at method 'methodExit'. What units of time are held in parameter "@Duration long time"?

package com.sun.btrace.samples;

import com.sun.btrace.Profiler;
import com.sun.btrace.annotations.*;
import static com.sun.btrace.BTraceUtils.*;
import java.awt.EventQueue;
import java.awt.AWTEvent;
import java.awt.event.FocusEvent;

@BTrace
public class AllMethods {

    @OnMethod(
        clazz="java.awt.EventQueue",
        method="dispatchEvent",
        location=@Location(Kind.RETURN))
    public static void methodExit(@Duration long time, @ProbeMethodName String pmn) {
        println(pmn + " " + (time / 1000000));
    }
}

Solution

  • The duration is measured in nanoseconds.

    The javadoc is missing this information - I have filed an issue for that. If you want to dig in the sources this place is a good start.