diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 527b562..7a65571 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -5,7 +5,6 @@ on: types: [labeled] env: - IAI_CALLGRIND_VERSION: 0.7.3 CARGO_TERM_COLOR: always IAI_CALLGRIND_COLOR: never CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse @@ -26,8 +25,13 @@ jobs: - uses: dtolnay/rust-toolchain@stable - uses: taiki-e/install-action@valgrind - uses: taiki-e/install-action@cargo-binstall - - name: Install iai-callgrind-runner - run: cargo binstall --no-confirm --no-symlinks iai-callgrind-runner --version ${IAI_CALLGRIND_VERSION} + - name: Install iai-callgrind-runner for base branch + run: | + version=$(cargo metadata --format-version=1 |\ + jq '.packages[] | select(.name == "iai-callgrind").version' |\ + tr -d '"' + ) + cargo binstall --no-confirm --no-symlinks iai-callgrind-runner --version "${version}" - name: Bench base branch run: | cargo update @@ -36,6 +40,13 @@ jobs: with: ref: ${{ github.event.pull_request.head.ref }} clean: false + - name: Install iai-callgrind-runner for head branch + run: | + version=$(cargo metadata --format-version=1 |\ + jq '.packages[] | select(.name == "iai-callgrind").version' |\ + tr -d '"' + ) + cargo binstall --no-confirm --no-symlinks iai-callgrind-runner --version "${version}" - name: Bench head branch run: | cargo update @@ -44,6 +55,13 @@ jobs: with: ref: ${{ github.event.pull_request.base.ref }} clean: false + - name: Install iai-callgrind-runner for base branch no finalization + run: | + version=$(cargo metadata --format-version=1 |\ + jq '.packages[] | select(.name == "iai-callgrind").version' |\ + tr -d '"' + ) + cargo binstall --no-confirm --no-symlinks iai-callgrind-runner --version "${version}" - name: Bench base branch no finalization run: | cargo clean @@ -53,6 +71,13 @@ jobs: with: ref: ${{ github.event.pull_request.head.ref }} clean: false + - name: Install iai-callgrind-runner for head branch no finalization + run: | + version=$(cargo metadata --format-version=1 |\ + jq '.packages[] | select(.name == "iai-callgrind").version' |\ + tr -d '"' + ) + cargo binstall --no-confirm --no-symlinks iai-callgrind-runner --version "${version}" - name: Bench head branch no finalization run: | cargo update diff --git a/Cargo.toml b/Cargo.toml index af35b42..c576385 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,7 +54,7 @@ slotmap = { version = "1.0", optional = true } thiserror = { version = "1.0", package = "thiserror-core", default-features = false } [dev-dependencies] -iai-callgrind = "=0.7.3" # Also update IAI_CALLGRIND_VERSION in .github/workflows/bench.yml +iai-callgrind = "=0.12.1" rand = "0.8.3" trybuild = "1.0.85" test-case = "3.3.1" @@ -64,6 +64,10 @@ name = "bench" harness = false required-features = ["std", "derive"] +[profile.bench] +debug = true # Required by iai-callgrind +strip = false # Required by iai-callgrind + [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(doc_auto_cfg)'] } diff --git a/benches/bench.rs b/benches/bench.rs index 1cbd4ee..51bdbec 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -8,7 +8,7 @@ mod benches { } use std::hint::black_box; -use iai_callgrind::{library_benchmark, library_benchmark_group, main}; +use iai_callgrind::{library_benchmark, library_benchmark_group, LibraryBenchmarkConfig, main}; use crate::benches::binary_trees::count_binary_trees; use crate::benches::binary_trees_with_parent_pointers::count_binary_trees_with_parent; use crate::benches::large_linked_list::large_linked_list; @@ -53,4 +53,7 @@ library_benchmark_group!( benchmarks = large_linked_list_bench ); -main!(library_benchmark_groups = stress_tests_group, binary_trees_group, linked_lists_group); +main!( + config = LibraryBenchmarkConfig::default().raw_callgrind_args(["--branch-sim=yes"]); + library_benchmark_groups = stress_tests_group, binary_trees_group, linked_lists_group +);