Dreaming about bnchmarking function call

I don't know whether it is possible or not yet but it would be nice to have a function, say

fn add_two(x: u8) -> u8 {
    x + 2
}

And a possibility to benchmark it simply by adding a compiler macro:

#[bench]
fn add_two(x: u8) -> u8 {
    x + 2
}

This is better than having benchmark tests separated because tests are done in test environment while this - not.

I'd like to #[bench] work with options:

  • Put output to a file
  • Optionally benchmark nested functions and/or lines of the code and not only the start/end of the function

Is my dream good enough?

Have you seen https://github.com/TyOverby/flame? It does something similar.

Looks like it is, thanks :slight_smile: