firestorm icon indicating copy to clipboard operation
firestorm copied to clipboard

Procedure macro

Open cmpute opened this issue 3 years ago • 1 comments
trafficstars

I think it will be more idiomatic to mark the profiling function like this

#[profile_fn]
fn fn_name<T>(param: T) {
    // If a function is complex, profile a section.
    #[profile_section]
    {
        // Optional: manually drop.
        // Section automatically drops when going out of scope.
        drop(inner);
    }
}

This API looks like the profiling crate, and it looks more ergonomic to me.

cmpute avatar May 14 '22 06:05 cmpute

I agree that appears less verbose, and is especially nice in that the function signature need not be duplicated. IDE support for macros can be hit or miss though. Also, sometimes compile times can be negatively affected. So, it's not a clear win. We could provide it as an option though.

That3Percent avatar May 16 '22 13:05 That3Percent