Skip to content

tests: add an env variable bench for testing #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ jobs:

compat-integration-test-instrumentation:
runs-on: ubuntu-latest
strategy:
matrix:
build-args:
- "-p codspeed"
- "-p codspeed-bencher-compat"
- "--features async_futures -p codspeed-criterion-compat"
- "-p codspeed-divan-compat"
- "-p codspeed-divan-compat-examples"
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -58,21 +66,24 @@ jobs:

- run: cargo install --path crates/cargo-codspeed --locked

- run: cargo codspeed build -p codspeed
- run: cargo codspeed build -p codspeed-bencher-compat
- run: cargo codspeed build --features async_futures -p codspeed-criterion-compat

- run: cargo codspeed build -p codspeed-divan-compat
- run: cargo codspeed build -p codspeed-divan-compat-examples
- run: cargo codspeed build ${{ matrix.build-args }}

- name: Run the benchmarks
uses: CodSpeedHQ/action@main
env:
MY_ENV_VAR: "YES"
with:
run: cargo codspeed run
token: ${{ secrets.CODSPEED_TOKEN }}

compat-integration-test-walltime:
runs-on: codspeed-macro
strategy:
matrix:
package:
- codspeed-divan-compat
- codspeed-divan-compat-examples
- codspeed-criterion-compat
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -83,12 +94,26 @@ jobs:

- run: cargo install --path crates/cargo-codspeed --locked

- run: cargo codspeed build -p codspeed-divan-compat
- run: cargo codspeed build -p codspeed-divan-compat-examples
- run: cargo codspeed build -p codspeed-criterion-compat
- run: cargo codspeed build -p ${{ matrix.package }}

- name: Run the benchmarks
uses: CodSpeedHQ/action@main
env:
MY_ENV_VAR: "YES"
with:
run: cargo codspeed run
token: ${{ secrets.CODSPEED_TOKEN }}

check:
runs-on: ubuntu-latest
if: always()
needs:
- lint
- msrv-check
- tests
- compat-integration-test-instrumentation
- compat-integration-test-walltime
steps:
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJson( needs ) }}
4 changes: 4 additions & 0 deletions crates/divan_compat/examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ harness = false
name = "time_scale"
harness = false

[[bench]]
name = "env"
harness = false

[[bench]]
name = "the_algorithms"
harness = false
9 changes: 9 additions & 0 deletions crates/divan_compat/examples/benches/env.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fn main() {
divan::main();
}

#[divan::bench]
fn print_env_hello() {
let env_var = std::env::var("MY_ENV_VAR").unwrap_or("not set".to_string());
println!("MY_ENV_VAR is {}", env_var);
}