From 199d0c08a6ab7e7b0001581c7d1de29c4a0352b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Vask=C3=B3?= <1771332+vlaci@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:17:11 +0100 Subject: [PATCH 1/2] fix(rust/benchmark): follow-up package rename Also, use `unblob` name, as it will only be visible in rust --- rust/Cargo.toml | 2 +- rust/benches/benches_main.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index e78e8dbdf9..5968f21aba 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -11,7 +11,7 @@ crate-type = [ "cdylib", # for Python extension "rlib", # for benchmarking ] -name = "unblob_rust" +name = "unblob" [dependencies] log = "0.4.22" diff --git a/rust/benches/benches_main.rs b/rust/benches/benches_main.rs index d32eabe375..edd92d534a 100755 --- a/rust/benches/benches_main.rs +++ b/rust/benches/benches_main.rs @@ -19,7 +19,7 @@ fn shannon_entropy(c: &mut Criterion) { BenchmarkId::from_parameter(sample_size), &sample_size, |b, &size| { - b.iter(|| unblob_native::math_tools::shannon_entropy(&sample[0..size])); + b.iter(|| unblob::math_tools::shannon_entropy(&sample[0..size])); }, ); } @@ -38,7 +38,7 @@ fn chi_square_probability(c: &mut Criterion) { BenchmarkId::from_parameter(sample_size), &sample_size, |b, &size| { - b.iter(|| unblob_native::math_tools::chi_square_probability(&sample[0..size])); + b.iter(|| unblob::math_tools::chi_square_probability(&sample[0..size])); }, ); } From e299bb603ec15acdc2b68d8b25b763a1cf6d7235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Vask=C3=B3?= <1771332+vlaci@users.noreply.github.com> Date: Mon, 10 Feb 2025 17:06:15 +0100 Subject: [PATCH 2/2] ci: run cargo benchmark --- .github/workflows/CI.yml | 15 +++++++++++++++ rust/Cargo.toml | 3 +++ 2 files changed, 18 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b6c95979ee..bbad1ab805 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -103,6 +103,21 @@ jobs: SCCACHE_GHA_ENABLED: "true" RUSTC_WRAPPER: "sccache" run: cargo test + - name: Run benchmark + if: matrix.os == 'ubuntu-latest' + env: + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + run: cargo bench -- --output-format bencher | tee bench.txt + - name: Store benchmark result + if: matrix.os == 'ubuntu-latest' + uses: benchmark-action/github-action-benchmark@v1 + with: + tool: "cargo" + output-file-path: bench.txt + summary-always: true + comment-on-alert: true + github-token: ${{ secrets.GITHUB_TOKEN }} build_linux_wheels: name: Build wheels (linux) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 5968f21aba..6a018eb34d 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -12,6 +12,9 @@ crate-type = [ "rlib", # for benchmarking ] name = "unblob" +# disable Rust nightly benchmark feature. We use criterion +# https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options +bench = false [dependencies] log = "0.4.22"