diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20e423ab..40cbd783 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,44 +59,45 @@ jobs: - uses: moonrepo/setup-rust@v1 - run: cargo test --all - compat-integration-test-instrumentation: - runs-on: ubuntu-latest - strategy: - matrix: - build-args: - - "-p codspeed" - - "-p codspeed-bencher-compat" - - "--features async_futures -p codspeed-criterion-compat" - - "-p codspeed-divan-compat" - - "-p codspeed-divan-compat-examples" - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - uses: moonrepo/setup-rust@v1 - with: - cache-target: release + # compat-integration-test-instrumentation: + # runs-on: ubuntu-latest + # strategy: + # matrix: + # build-args: + # - "-p codspeed" + # - "-p codspeed-bencher-compat" + # - "--features async_futures -p codspeed-criterion-compat" + # - "-p codspeed-divan-compat" + # - "-p codspeed-divan-compat-examples" + # steps: + # - uses: actions/checkout@v4 + # with: + # submodules: true + # - uses: moonrepo/setup-rust@v1 + # with: + # cache-target: release - - run: cargo install --path crates/cargo-codspeed --locked + # - run: cargo install --path crates/cargo-codspeed --locked - - run: cargo codspeed build ${{ matrix.build-args }} + # - run: cargo codspeed build ${{ matrix.build-args }} - - name: Run the benchmarks - uses: CodSpeedHQ/action@main - env: - MY_ENV_VAR: "YES" - with: - run: cargo codspeed run - token: ${{ secrets.CODSPEED_TOKEN }} + # - name: Run the benchmarks + # uses: CodSpeedHQ/action@main + # env: + # MY_ENV_VAR: "YES" + # with: + # mode: instrumentation + # run: cargo codspeed run + # token: ${{ secrets.CODSPEED_TOKEN }} compat-integration-test-walltime: runs-on: codspeed-macro strategy: matrix: package: - - codspeed-divan-compat + # - codspeed-divan-compat - codspeed-divan-compat-examples - - codspeed-criterion-compat + # - codspeed-criterion-compat steps: - uses: actions/checkout@v4 with: @@ -113,11 +114,13 @@ jobs: cargo codspeed build -p ${{ matrix.package }} - name: Run the benchmarks - uses: CodSpeedHQ/action@main + uses: CodSpeedHQ/action@chore/runner-branch env: MY_ENV_VAR: "YES" CODSPEED_PERF_ENABLED: true with: + runner-branch: cod-1344-investigate-benchmark-time-in-drop_in_place-and-perf + mode: walltime run: cargo codspeed run token: ${{ secrets.CODSPEED_TOKEN }} @@ -129,7 +132,6 @@ jobs: - lint-windows - msrv-check - tests - - compat-integration-test-instrumentation - compat-integration-test-walltime steps: - uses: re-actors/alls-green@release/v1 diff --git a/crates/divan_compat/examples/Cargo.toml b/crates/divan_compat/examples/Cargo.toml index 188a5c0c..57756313 100644 --- a/crates/divan_compat/examples/Cargo.toml +++ b/crates/divan_compat/examples/Cargo.toml @@ -17,25 +17,25 @@ num-traits = { version = "0.2", optional = true } default = ["big-math"] big-math = ["num-bigint", "num-traits"] -[[bench]] -name = "math" -harness = false +# [[bench]] +# name = "math" +# harness = false -[[bench]] -name = "sort" -harness = false +# [[bench]] +# name = "sort" +# harness = false -[[bench]] -name = "time" -harness = false +# [[bench]] +# name = "time" +# harness = false -[[bench]] -name = "time_scale" -harness = false +# [[bench]] +# name = "time_scale" +# harness = false -[[bench]] -name = "env" -harness = false +# [[bench]] +# name = "env" +# harness = false [[bench]] name = "the_algorithms" diff --git a/crates/divan_compat/examples/benches/the_algorithms.rs b/crates/divan_compat/examples/benches/the_algorithms.rs index b996f41c..b7c66c4a 100644 --- a/crates/divan_compat/examples/benches/the_algorithms.rs +++ b/crates/divan_compat/examples/benches/the_algorithms.rs @@ -10,24 +10,28 @@ mod backtracking { #[divan::bench(args = [4, 5, 6, 7, 8])] fn n_queens_solver(n: usize) -> Vec> { + println!("n_queens_solver for n = {}", n); the_algorithms::backtracking::n_queens_solver(n) } // Benchmark parentheses generation with different sizes #[divan::bench(args = [3, 4, 5, 6])] fn generate_parentheses(n: usize) -> Vec { + println!("generate_parentheses for n = {}", n); the_algorithms::backtracking::generate_parentheses(n) } // Benchmark combinations generation with different n values, keeping k=3 #[divan::bench(args = [5, 6, 7, 8, 9])] fn generate_combinations(n: usize) -> Vec> { + println!("generate_combinations for n = {}", n); the_algorithms::backtracking::generate_all_combinations(n, 3).unwrap() } // Benchmark graph coloring with different sizes of complete graphs #[divan::bench(args = [3, 4, 5, 6])] fn graph_coloring(bencher: divan::Bencher, n: usize) { + println!("graph_coloring for n = {}", n); // Create a complete graph of size n (all vertices connected to each other) let matrix = (0..n) .map(|i| (0..n).map(|j| i != j).collect()) @@ -44,6 +48,7 @@ mod backtracking { // Benchmark Hamiltonian cycle finding with different sizes of cyclic graphs #[divan::bench(args = [4, 5, 6, 7])] fn hamiltonian_cycle(bencher: divan::Bencher, n: usize) { + println!("hamiltonian_cycle for n = {}", n); // Create a cyclic graph where each vertex is connected to its neighbors // This ensures a Hamiltonian cycle exists let matrix = (0..n) @@ -69,6 +74,7 @@ mod backtracking { // Benchmark Knight's Tour with different board sizes #[divan::bench(args = [5, 6, 7, 8])] fn knight_tour(bencher: divan::Bencher, n: usize) { + println!("knight_tour for n = {}", n); bencher.bench_local(|| { black_box(the_algorithms::backtracking::find_knight_tour( black_box(n), @@ -82,6 +88,7 @@ mod backtracking { // Benchmark permutations with different input sizes #[divan::bench(args = [3, 4, 5, 6, 7])] fn permutations(bencher: divan::Bencher, n: usize) { + println!("permutations for n = {}", n); let nums: Vec = (0..n).map(|x| x as isize).collect(); bencher.bench_local(|| { @@ -94,6 +101,7 @@ mod backtracking { // Benchmark Rat in Maze with different maze sizes #[divan::bench(args = [5, 6, 7, 8])] fn rat_in_maze(bencher: divan::Bencher, n: usize) { + println!("rat_in_maze for n = {}", n); // Create a maze where the rat can move diagonally to the end let maze = (0..n) .map(|i| (0..n).map(|j| i == j || i == j + 1).collect()) @@ -111,6 +119,7 @@ mod backtracking { // Benchmark Subset Sum with different set sizes #[divan::bench(args = [10, 12, 14, 16, 18])] fn subset_sum(bencher: divan::Bencher, n: usize) { + println!("subset_sum for n = {}", n); let set: Vec = (0..n).map(|x| x as isize).collect(); let target = (n as isize) * 2; // A challenging but achievable target @@ -125,6 +134,7 @@ mod backtracking { // Benchmark Sudoku solver with different levels of difficulty #[divan::bench] fn sudoku(bencher: divan::Bencher) { + println!("sudoku solver benchmark"); // A moderately difficult Sudoku puzzle let board = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], @@ -146,43 +156,43 @@ mod backtracking { } } -mod bit_manipulation { - use super::*; - - #[divan::bench(args = [0, 42, 255, 1024, 65535])] - fn count_set_bits(bencher: divan::Bencher, n: u32) { - bencher.bench_local(|| { - black_box(the_algorithms::bit_manipulation::count_set_bits(black_box( - n.try_into().unwrap(), - ))) - }); - } - - #[divan::bench(args = [0, 42, 255, 1024, 65535])] - fn find_highest_set_bit(bencher: divan::Bencher, n: u32) { - bencher.bench_local(|| { - black_box(the_algorithms::bit_manipulation::find_highest_set_bit( - black_box(n.try_into().unwrap()), - )) - }); - } - - #[divan::bench(args = [1, 2, 3, 4, 5])] - fn generate_gray_code(bencher: divan::Bencher, n: u32) { - bencher.bench_local(|| { - black_box(the_algorithms::bit_manipulation::generate_gray_code( - black_box(n.try_into().unwrap()), - )) - }); - } - - #[divan::bench(args = &[(0, 0), (42, 13), (255, 255), (1024, -1024), (65535, -65535)])] - fn add_two_integers(bencher: divan::Bencher, (a, b): (i32, i32)) { - bencher.bench_local(|| { - black_box(the_algorithms::bit_manipulation::add_two_integers( - black_box(a.try_into().unwrap()), - black_box(b.try_into().unwrap()), - )) - }); - } -} +// mod bit_manipulation { +// use super::*; + +// #[divan::bench(args = [0, 42, 255, 1024, 65535])] +// fn count_set_bits(bencher: divan::Bencher, n: u32) { +// bencher.bench_local(|| { +// black_box(the_algorithms::bit_manipulation::count_set_bits(black_box( +// n.try_into().unwrap(), +// ))) +// }); +// } + +// #[divan::bench(args = [0, 42, 255, 1024, 65535])] +// fn find_highest_set_bit(bencher: divan::Bencher, n: u32) { +// bencher.bench_local(|| { +// black_box(the_algorithms::bit_manipulation::find_highest_set_bit( +// black_box(n.try_into().unwrap()), +// )) +// }); +// } + +// #[divan::bench(args = [1, 2, 3, 4, 5])] +// fn generate_gray_code(bencher: divan::Bencher, n: u32) { +// bencher.bench_local(|| { +// black_box(the_algorithms::bit_manipulation::generate_gray_code( +// black_box(n.try_into().unwrap()), +// )) +// }); +// } + +// #[divan::bench(args = &[(0, 0), (42, 13), (255, 255), (1024, -1024), (65535, -65535)])] +// fn add_two_integers(bencher: divan::Bencher, (a, b): (i32, i32)) { +// bencher.bench_local(|| { +// black_box(the_algorithms::bit_manipulation::add_two_integers( +// black_box(a.try_into().unwrap()), +// black_box(b.try_into().unwrap()), +// )) +// }); +// } +// }