Skip to content

Commit

Permalink
Use runtime arguments in Divan benchmarks
Browse files Browse the repository at this point in the history
This greatly reduces compile times and is not limited to arrays/slices.
  • Loading branch information
nvzqz committed Jan 21, 2024
1 parent 510bd92 commit 7cb124c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 30 deletions.
31 changes: 6 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false

[dependencies]
pomsky = { version = "0.11.0", path = "../pomsky-lib" }
divan = "0.1.2"
divan = "0.1.11"
melody_compiler = "0.19.0"

[[bench]]
Expand Down
8 changes: 4 additions & 4 deletions benchmark/benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ mod compile {
);
}

#[divan::bench(consts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])]
pub fn range<const N: usize>(bencher: divan::Bencher) {
let max = "3458709621".repeat((N + 9) / 10);
let max = &max[..N];
#[divan::bench(args = 1..=13)]
pub fn range(bencher: divan::Bencher, n: usize) {
let max = "3458709621".repeat((n + 9) / 10);
let max = &max[..n];
let input = format!("range '0'-'{max}'");

bencher
Expand Down

0 comments on commit 7cb124c

Please sign in to comment.