diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml new file mode 100644 index 00000000..299b8e40 --- /dev/null +++ b/.github/workflows/bench.yml @@ -0,0 +1,24 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + CARGO_TERM_COLOR: always + +jobs: + iai: + name: Bench (iai) + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Install Valgrind + run: apt install valgrind + - name: Build + run: cargo build --verbose + - name: Bench + run: cargo bench --verbose diff --git a/Cargo.toml b/Cargo.toml index 55339849..164da57e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,8 @@ petgraph = "0.6.2" rsgm = { git = "https://github.com/pmall-neu/rsgm" } rand_chacha = "0.3.1" +[dev-dependencies] +iai = "0.1" [lib] name = "rsdd" @@ -59,3 +61,7 @@ path = "bin/bayesian_network_compiler.rs" [[bin]] name = "semantic_hash_experiment" path = "bin/semantic_hash_experiment.rs" + +[[bench]] +name = "iai" +harness = false diff --git a/benches/iai.rs b/benches/iai.rs new file mode 100644 index 00000000..6db74acf --- /dev/null +++ b/benches/iai.rs @@ -0,0 +1,20 @@ +use iai::black_box; + +fn fibonacci(n: u64) -> u64 { + match n { + 0 => 1, + 1 => 1, + n => fibonacci(n-1) + fibonacci(n-2), + } +} + +fn iai_benchmark_short() -> u64 { + fibonacci(black_box(10)) +} + +fn iai_benchmark_long() -> u64 { + fibonacci(black_box(30)) +} + + +iai::main!(iai_benchmark_short, iai_benchmark_long);