Dreaming about bnchmarking function call


#1

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?


#2

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


#3

Looks like it is, thanks :slight_smile: