Skip to content

Commit dbf127d

Browse files
committed
wip: run certain benches
1 parent 0565866 commit dbf127d

3 files changed

Lines changed: 95 additions & 83 deletions

File tree

.github/workflows/ci.yml

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,44 +59,45 @@ jobs:
5959
- uses: moonrepo/setup-rust@v1
6060
- run: cargo test --all
6161

62-
compat-integration-test-instrumentation:
63-
runs-on: ubuntu-latest
64-
strategy:
65-
matrix:
66-
build-args:
67-
- "-p codspeed"
68-
- "-p codspeed-bencher-compat"
69-
- "--features async_futures -p codspeed-criterion-compat"
70-
- "-p codspeed-divan-compat"
71-
- "-p codspeed-divan-compat-examples"
72-
steps:
73-
- uses: actions/checkout@v4
74-
with:
75-
submodules: true
76-
- uses: moonrepo/setup-rust@v1
77-
with:
78-
cache-target: release
62+
# compat-integration-test-instrumentation:
63+
# runs-on: ubuntu-latest
64+
# strategy:
65+
# matrix:
66+
# build-args:
67+
# - "-p codspeed"
68+
# - "-p codspeed-bencher-compat"
69+
# - "--features async_futures -p codspeed-criterion-compat"
70+
# - "-p codspeed-divan-compat"
71+
# - "-p codspeed-divan-compat-examples"
72+
# steps:
73+
# - uses: actions/checkout@v4
74+
# with:
75+
# submodules: true
76+
# - uses: moonrepo/setup-rust@v1
77+
# with:
78+
# cache-target: release
7979

80-
- run: cargo install --path crates/cargo-codspeed --locked
80+
# - run: cargo install --path crates/cargo-codspeed --locked
8181

82-
- run: cargo codspeed build ${{ matrix.build-args }}
82+
# - run: cargo codspeed build ${{ matrix.build-args }}
8383

84-
- name: Run the benchmarks
85-
uses: CodSpeedHQ/action@main
86-
env:
87-
MY_ENV_VAR: "YES"
88-
with:
89-
run: cargo codspeed run
90-
token: ${{ secrets.CODSPEED_TOKEN }}
84+
# - name: Run the benchmarks
85+
# uses: CodSpeedHQ/action@main
86+
# env:
87+
# MY_ENV_VAR: "YES"
88+
# with:
89+
# mode: instrumentation
90+
# run: cargo codspeed run
91+
# token: ${{ secrets.CODSPEED_TOKEN }}
9192

9293
compat-integration-test-walltime:
9394
runs-on: codspeed-macro
9495
strategy:
9596
matrix:
9697
package:
97-
- codspeed-divan-compat
98+
# - codspeed-divan-compat
9899
- codspeed-divan-compat-examples
99-
- codspeed-criterion-compat
100+
# - codspeed-criterion-compat
100101
steps:
101102
- uses: actions/checkout@v4
102103
with:
@@ -118,6 +119,7 @@ jobs:
118119
MY_ENV_VAR: "YES"
119120
CODSPEED_PERF_ENABLED: true
120121
with:
122+
mode: walltime
121123
run: cargo codspeed run
122124
token: ${{ secrets.CODSPEED_TOKEN }}
123125

crates/divan_compat/examples/Cargo.toml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ num-traits = { version = "0.2", optional = true }
1717
default = ["big-math"]
1818
big-math = ["num-bigint", "num-traits"]
1919

20-
[[bench]]
21-
name = "math"
22-
harness = false
20+
# [[bench]]
21+
# name = "math"
22+
# harness = false
2323

24-
[[bench]]
25-
name = "sort"
26-
harness = false
24+
# [[bench]]
25+
# name = "sort"
26+
# harness = false
2727

28-
[[bench]]
29-
name = "time"
30-
harness = false
28+
# [[bench]]
29+
# name = "time"
30+
# harness = false
3131

32-
[[bench]]
33-
name = "time_scale"
34-
harness = false
32+
# [[bench]]
33+
# name = "time_scale"
34+
# harness = false
3535

36-
[[bench]]
37-
name = "env"
38-
harness = false
36+
# [[bench]]
37+
# name = "env"
38+
# harness = false
3939

4040
[[bench]]
4141
name = "the_algorithms"

crates/divan_compat/examples/benches/the_algorithms.rs

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,28 @@ mod backtracking {
1010

1111
#[divan::bench(args = [4, 5, 6, 7, 8])]
1212
fn n_queens_solver(n: usize) -> Vec<Vec<String>> {
13+
println!("n_queens_solver for n = {}", n);
1314
the_algorithms::backtracking::n_queens_solver(n)
1415
}
1516

1617
// Benchmark parentheses generation with different sizes
1718
#[divan::bench(args = [3, 4, 5, 6])]
1819
fn generate_parentheses(n: usize) -> Vec<String> {
20+
println!("generate_parentheses for n = {}", n);
1921
the_algorithms::backtracking::generate_parentheses(n)
2022
}
2123

2224
// Benchmark combinations generation with different n values, keeping k=3
2325
#[divan::bench(args = [5, 6, 7, 8, 9])]
2426
fn generate_combinations(n: usize) -> Vec<Vec<usize>> {
27+
println!("generate_combinations for n = {}", n);
2528
the_algorithms::backtracking::generate_all_combinations(n, 3).unwrap()
2629
}
2730

2831
// Benchmark graph coloring with different sizes of complete graphs
2932
#[divan::bench(args = [3, 4, 5, 6])]
3033
fn graph_coloring(bencher: divan::Bencher, n: usize) {
34+
println!("graph_coloring for n = {}", n);
3135
// Create a complete graph of size n (all vertices connected to each other)
3236
let matrix = (0..n)
3337
.map(|i| (0..n).map(|j| i != j).collect())
@@ -44,6 +48,7 @@ mod backtracking {
4448
// Benchmark Hamiltonian cycle finding with different sizes of cyclic graphs
4549
#[divan::bench(args = [4, 5, 6, 7])]
4650
fn hamiltonian_cycle(bencher: divan::Bencher, n: usize) {
51+
println!("hamiltonian_cycle for n = {}", n);
4752
// Create a cyclic graph where each vertex is connected to its neighbors
4853
// This ensures a Hamiltonian cycle exists
4954
let matrix = (0..n)
@@ -69,6 +74,7 @@ mod backtracking {
6974
// Benchmark Knight's Tour with different board sizes
7075
#[divan::bench(args = [5, 6, 7, 8])]
7176
fn knight_tour(bencher: divan::Bencher, n: usize) {
77+
println!("knight_tour for n = {}", n);
7278
bencher.bench_local(|| {
7379
black_box(the_algorithms::backtracking::find_knight_tour(
7480
black_box(n),
@@ -82,6 +88,7 @@ mod backtracking {
8288
// Benchmark permutations with different input sizes
8389
#[divan::bench(args = [3, 4, 5, 6, 7])]
8490
fn permutations(bencher: divan::Bencher, n: usize) {
91+
println!("permutations for n = {}", n);
8592
let nums: Vec<isize> = (0..n).map(|x| x as isize).collect();
8693

8794
bencher.bench_local(|| {
@@ -94,6 +101,7 @@ mod backtracking {
94101
// Benchmark Rat in Maze with different maze sizes
95102
#[divan::bench(args = [5, 6, 7, 8])]
96103
fn rat_in_maze(bencher: divan::Bencher, n: usize) {
104+
println!("rat_in_maze for n = {}", n);
97105
// Create a maze where the rat can move diagonally to the end
98106
let maze = (0..n)
99107
.map(|i| (0..n).map(|j| i == j || i == j + 1).collect())
@@ -111,6 +119,7 @@ mod backtracking {
111119
// Benchmark Subset Sum with different set sizes
112120
#[divan::bench(args = [10, 12, 14, 16, 18])]
113121
fn subset_sum(bencher: divan::Bencher, n: usize) {
122+
println!("subset_sum for n = {}", n);
114123
let set: Vec<isize> = (0..n).map(|x| x as isize).collect();
115124
let target = (n as isize) * 2; // A challenging but achievable target
116125

@@ -125,6 +134,7 @@ mod backtracking {
125134
// Benchmark Sudoku solver with different levels of difficulty
126135
#[divan::bench]
127136
fn sudoku(bencher: divan::Bencher) {
137+
println!("sudoku solver benchmark");
128138
// A moderately difficult Sudoku puzzle
129139
let board = [
130140
[3, 0, 6, 5, 0, 8, 4, 0, 0],
@@ -146,43 +156,43 @@ mod backtracking {
146156
}
147157
}
148158

149-
mod bit_manipulation {
150-
use super::*;
151-
152-
#[divan::bench(args = [0, 42, 255, 1024, 65535])]
153-
fn count_set_bits(bencher: divan::Bencher, n: u32) {
154-
bencher.bench_local(|| {
155-
black_box(the_algorithms::bit_manipulation::count_set_bits(black_box(
156-
n.try_into().unwrap(),
157-
)))
158-
});
159-
}
160-
161-
#[divan::bench(args = [0, 42, 255, 1024, 65535])]
162-
fn find_highest_set_bit(bencher: divan::Bencher, n: u32) {
163-
bencher.bench_local(|| {
164-
black_box(the_algorithms::bit_manipulation::find_highest_set_bit(
165-
black_box(n.try_into().unwrap()),
166-
))
167-
});
168-
}
169-
170-
#[divan::bench(args = [1, 2, 3, 4, 5])]
171-
fn generate_gray_code(bencher: divan::Bencher, n: u32) {
172-
bencher.bench_local(|| {
173-
black_box(the_algorithms::bit_manipulation::generate_gray_code(
174-
black_box(n.try_into().unwrap()),
175-
))
176-
});
177-
}
178-
179-
#[divan::bench(args = &[(0, 0), (42, 13), (255, 255), (1024, -1024), (65535, -65535)])]
180-
fn add_two_integers(bencher: divan::Bencher, (a, b): (i32, i32)) {
181-
bencher.bench_local(|| {
182-
black_box(the_algorithms::bit_manipulation::add_two_integers(
183-
black_box(a.try_into().unwrap()),
184-
black_box(b.try_into().unwrap()),
185-
))
186-
});
187-
}
188-
}
159+
// mod bit_manipulation {
160+
// use super::*;
161+
162+
// #[divan::bench(args = [0, 42, 255, 1024, 65535])]
163+
// fn count_set_bits(bencher: divan::Bencher, n: u32) {
164+
// bencher.bench_local(|| {
165+
// black_box(the_algorithms::bit_manipulation::count_set_bits(black_box(
166+
// n.try_into().unwrap(),
167+
// )))
168+
// });
169+
// }
170+
171+
// #[divan::bench(args = [0, 42, 255, 1024, 65535])]
172+
// fn find_highest_set_bit(bencher: divan::Bencher, n: u32) {
173+
// bencher.bench_local(|| {
174+
// black_box(the_algorithms::bit_manipulation::find_highest_set_bit(
175+
// black_box(n.try_into().unwrap()),
176+
// ))
177+
// });
178+
// }
179+
180+
// #[divan::bench(args = [1, 2, 3, 4, 5])]
181+
// fn generate_gray_code(bencher: divan::Bencher, n: u32) {
182+
// bencher.bench_local(|| {
183+
// black_box(the_algorithms::bit_manipulation::generate_gray_code(
184+
// black_box(n.try_into().unwrap()),
185+
// ))
186+
// });
187+
// }
188+
189+
// #[divan::bench(args = &[(0, 0), (42, 13), (255, 255), (1024, -1024), (65535, -65535)])]
190+
// fn add_two_integers(bencher: divan::Bencher, (a, b): (i32, i32)) {
191+
// bencher.bench_local(|| {
192+
// black_box(the_algorithms::bit_manipulation::add_two_integers(
193+
// black_box(a.try_into().unwrap()),
194+
// black_box(b.try_into().unwrap()),
195+
// ))
196+
// });
197+
// }
198+
// }

0 commit comments

Comments
 (0)