Skip to content

Commit

Permalink
Gate benchmarks behind feature flag
Browse files Browse the repository at this point in the history
This way everything should build on stable, and you can enable the
nighly-only benchmarks explicitly if you want to.

It would be nice if there were a way to just detect if we're on nightly,
but if there is I can't find it!
  • Loading branch information
Julian Andrews committed Feb 5, 2021
1 parent 918f62e commit 33f0904
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 33 deletions.
37 changes: 34 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
Expand All @@ -25,12 +25,28 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
Expand All @@ -39,10 +55,25 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings

benchmark:
name: Benchmark
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- uses: actions-rs/cargo@v1
with:
command: bench
args: --features benchmarks
56 changes: 27 additions & 29 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ edition = "2018"
getopts = "0.2"
rand = "0.7.3"

[features]
benchmarks = []

[[bin]]
path = "src/main.rs"
name = "markovpass"
4 changes: 4 additions & 0 deletions src/lib/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(feature = "benchmarks")]
extern crate test;

mod corpus;
Expand Down Expand Up @@ -44,6 +45,7 @@ mod tests {
assert_eq!(passphrases.len(), 5);
}

#[cfg(feature = "benchmarks")]
#[bench]
fn bench_gen_passphrases(b: &mut test::Bencher) {
let options = get_test_options();
Expand All @@ -67,3 +69,5 @@ mod tests {
}
}
}

mod bench {}
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(test)]
#![cfg_attr(feature = "benchmarks", feature(test))]

mod args;
mod lib;
Expand Down

0 comments on commit 33f0904

Please sign in to comment.