Skip to content

Relative percentage should take batch size into account #131

@helmesjo

Description

@helmesjo

Consider this:

bench::Bench b;
b.relative(true).unit("item");

b.batch(100'000)
  .run("baseline",
       []
       {
          // single-threaded, so batch size has little to none impact on
          // ns/item but is too slow with the larger batch size (5-10s).
       });

b.batch(1'000'000)
  .run("relative",
       []
       {
          // multi-threaded, and a larger batch size is needed to peak
          // out. Duration is less affected by batch size.
       });

Documentation states:
$100\% * \frac{baseline}{runtime}$
which I assume means it ignores the batch size. If so, I think it should be changed to something like:
$100\% * \frac{baselinePerItem}{runtimePerItem}$
Which, theoretically, should be same-same if the batch() size is unassigned.

Without this the relative percentage is skewed when batch size differs, and one would have to chose between skewed percentage (other stats are of course correct) or a very slow-running benchmark.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions