Attribute Macro gdnative_derive::profiled[][src]

#[profiled]

Makes a function profiled in Godot's built-in profiler. This macro automatically creates a tag using the name of the current module and the function by default.

This attribute may also be used on non-exported functions. If the GDNative API isn't initialized when the function is called, the data will be ignored silently.

A custom tag can also be provided using the tag option.

See the gdnative::nativescript::profiling for a lower-level API to the profiler with more control.

Examples

mod foo {
    // This function will show up as `foo/bar` under Script Functions.
    #[gdnative::profiled]
    fn bar() {
        std::thread::sleep(std::time::Duration::from_millis(1));
    }
}
// This function will show up as `my_custom_tag` under Script Functions.
#[gdnative::profiled(tag = "my_custom_tag")]
fn baz() {
    std::thread::sleep(std::time::Duration::from_millis(1));
}