Skip to content

Commit

Permalink
Enable codspeed for Rust perf tracking (#3231)
Browse files Browse the repository at this point in the history
Saw this in North Bay Python 2024, seems like a great complement for
`asv` on the Rust side

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
luizirber and pre-commit-ci[bot] authored Jul 24, 2024
1 parent ca89869 commit f621726
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 16 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: codspeed-benchmarks

on:
# Run on pushes to the main branch
push:
branches:
- "latest"
# Run on pull requests
pull_request:
# `workflow_dispatch` allows CodSpeed to trigger backtest
# performance analysis in order to generate initial data.
workflow_dispatch:

jobs:
benchmarks-rust:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup rust toolchain, cache and cargo-codspeed binary
uses: moonrepo/setup-rust@v0
with:
channel: stable
cache-target: release
bins: cargo-codspeed

- name: Build the benchmark target(s)
run: cargo codspeed build -p sourmash

- name: Run the benchmarks
uses: CodSpeedHQ/action@v2
with:
run: "cd src/core && cargo codspeed run"
token: ${{ secrets.CODSPEED_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: build
args: --all-features --tests
args: --all-features

check_cbindgen:
name: "Check if cbindgen runs cleanly for generating the C headers"
Expand Down
58 changes: 56 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
cargo-udeps
cargo-deny
cargo-wasi
cargo-codspeed
#cargo-semver-checks
nixpkgs-fmt
];
Expand Down
1 change: 1 addition & 0 deletions src/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ typed-builder = "0.18.0"
vec-collections = "0.4.3"

[dev-dependencies]
codspeed-criterion-compat = "2.6.0"
proptest = { version = "1.5.0", default-features = false, features = ["std"]}
rand = "0.8.2"
tempfile = "3.10.1"
Expand Down
5 changes: 1 addition & 4 deletions src/core/benches/compute.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#[macro_use]
extern crate criterion;
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion};

use std::fs::File;
use std::io::{Cursor, Read};
Expand All @@ -8,8 +7,6 @@ use needletail::parse_fastx_reader;
use sourmash::cmd::ComputeParameters;
use sourmash::signature::Signature;

use criterion::Criterion;

fn add_sequence(c: &mut Criterion) {
let cp = ComputeParameters::default();
let template_sig = Signature::from_params(&cp);
Expand Down
2 changes: 1 addition & 1 deletion src/core/benches/gather.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use sourmash::signature::Signature;
use sourmash::sketch::Sketch;
use sourmash::{index::calculate_gather_stats, storage::SigStore};

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion};

fn gather_stats_benchmarks(c: &mut Criterion) {
let mut filename = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
Expand Down
5 changes: 1 addition & 4 deletions src/core/benches/minhash.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[macro_use]
extern crate criterion;

use std::fs::File;
use std::io::BufReader;
use std::path::PathBuf;
Expand All @@ -9,7 +6,7 @@ use sourmash::signature::{Signature, SigsTrait};
use sourmash::sketch::minhash::{KmerMinHash, KmerMinHashBTree};
use sourmash::sketch::Sketch;

use criterion::Criterion;
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion};

fn intersection(c: &mut Criterion) {
let mut filename = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
Expand Down
5 changes: 1 addition & 4 deletions src/core/benches/nodegraph.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#[macro_use]
extern crate criterion;

use std::fs::File;
use std::io::{BufWriter, Cursor, Read};

use sourmash::sketch::nodegraph::Nodegraph;

use criterion::Criterion;
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion};

fn save_load(c: &mut Criterion) {
let mut data: Vec<u8> = vec![];
Expand Down

0 comments on commit f621726

Please sign in to comment.