Skip to content

Commit

Permalink
Move benchmarks to a new ring-bench crate.
Browse files Browse the repository at this point in the history
Move the Criterion.rs dependency out of *ring* into a new `ring-benches`
crate. This speeds up many build scenerios by eliminating a bunch of
dependencies from *ring*'s dependency tree for `cargo test`.
  • Loading branch information
briansmith committed Oct 7, 2023
1 parent f3273af commit 3d396bd
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 10 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ jobs:
- run: sh mk/package.sh
shell: bash

# Intentionally excludes benchmarks for build performance reasons.
test:
# Don't run duplicate `push` jobs for the repo owner's PRs.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
Expand Down Expand Up @@ -322,6 +323,28 @@ jobs:
(!contains(matrix.host_os, 'macos') || matrix.mode != '--release') }}
run: mk/check-symbol-prefixes.sh --target=${{ matrix.target }}

test-bench:
# Don't run duplicate `push` jobs for the repo owner's PRs.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

runs-on: ubuntu-22.04

steps:
- run: sudo apt-get update -y

- uses: briansmith/actions-checkout@v2
with:
persist-credentials: false

- run: mk/install-build-tools.sh --target=x86_64-unknown-linux-gnu

- uses: briansmith/actions-rs-toolchain@v1
with:
override: true
toolchain: stable

- run: cargo test -p ring-bench --all-features --all-targets

# XXX: GitHub Actions won't let us test all the combinations of features in
# the "test" matrix because the resultant matrix would be larger than the
# maximum they allow.
Expand Down
16 changes: 6 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,6 @@ libc = { version = "0.2.100", default-features = false }
[build-dependencies]
cc = { version = "1.0.69", default-features = false }

[dev-dependencies]
criterion = { version = "0.4", default-features = false }

[features]
# These features are documented in the top-level module's documentation.
default = ["alloc", "dev_urandom_fallback"]
Expand Down Expand Up @@ -225,10 +222,9 @@ lto = true
debug-assertions = false
codegen-units = 1

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

[[bench]]
name = "x25519"
harness = false
[workspace]
members = [
# intentionally not a default member so that `cargo test` doesn't cause criterion.rs and all its
# dependencies to get built.
"bench",
]
21 changes: 21 additions & 0 deletions bench/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
edition = "2021"
name = "ring-bench"
publish = false
version = "0.1.0"

[dependencies]
ring = { path = "../" }

[dev-dependencies]
criterion = { version = "0.4", default-features = false }

[[bench]]
name = "aead"
harness = false
path = "aead.rs"

[[bench]]
name = "x25519"
harness = false
path = "x25519.rs"
File renamed without changes.
File renamed without changes.

0 comments on commit 3d396bd

Please sign in to comment.