nvzqz / divan

Fast and simple benchmarking for Rust projects
https://nikolaivazquez.com/blog/divan/
Apache License 2.0
924 stars 26 forks source link

Allow for filtering beyond function names #5

Open nvzqz opened 1 year ago

nvzqz commented 1 year ago

Currently, filtering only works up to crate → module → function. Parameters to the function are not considered: generic types, constants, and thread counts.

The following code:

#[divan::bench(
    types = [i32, String],
    consts = [0, 42],
    threads = [1, 2],
)]
fn bench<T, const N: usize>() {}

...produces this output tree structure:

example
╰─ bench
   ├─ i32
   │  ├─ 0
   │  │  ├─ t=1
   │  │  ╰─ t=2
   │  ╰─ 42
   │     ├─ t=1
   │     ╰─ t=2
   ╰─ String
      ├─ 0
      │  ├─ t=1
      │  ╰─ t=2
      ╰─ 42
         ├─ t=1
         ╰─ t=2

However, we can only filter against example::bench. We cannot filter against example::bench::String::42::t=2. I think this is something we should try to support.

We should also consider whether we want benchmark parameters to be treated like namespacing when filtering. Perhaps instead they should be made to look more like Rust code: example::bench::<String, 42>(t=2)? I think the previous format is easier to reason about.