Skip to content

Commit 6849c5c

Browse files
authored
Add benchmarks (#16)
* ci: add benchmark CI job * chore: update bench example * build: add bencher deps & other metadata * chore: add bench tests & code refactor for perf * ci: reduce benchmark ci run time
1 parent 003f727 commit 6849c5c

File tree

12 files changed

+897
-758
lines changed

12 files changed

+897
-758
lines changed

.github/workflows/build.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,29 @@ jobs:
102102
run: cargo test --locked --release --no-run --workspace
103103

104104
# TODO: add fuzz tests
105-
# TODO: add benchmarks
105+
106+
benchmarks:
107+
name: Run benchmarks
108+
runs-on: ubuntu-20.04
109+
steps:
110+
- name: Checkout sources
111+
uses: actions/checkout@v4
112+
with:
113+
persist-credentials: false
114+
115+
- name: Install nightly toolchain
116+
uses: dtolnay/rust-toolchain@nightly
117+
118+
- name: Smoke-test benchmark program
119+
run: cargo run -p rustls-mbedcrypto-provider --release --locked --example bench
120+
env:
121+
# Ensure benchmark does not take too long time
122+
BENCH_MULTIPLIER: 0.3
123+
124+
- name: Run micro-benchmarks
125+
run: cargo bench --locked --all-features
126+
env:
127+
RUSTFLAGS: --cfg=bench
106128

107129
docs:
108130
name: Check for documentation errors

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rustls-mbedcrypto-provider/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ webpki-roots = "0.26.0"
4343
rustls-pemfile = "2"
4444
env_logger = "0.10"
4545
log = { version = "0.4.4" }
46+
bencher = "0.1.5"
4647

4748
[features]
4849
default = ["logging", "tls12"]
@@ -57,3 +58,10 @@ path = "examples/client.rs"
5758
[[example]]
5859
name = "bench"
5960
path = "examples/internal/bench.rs"
61+
62+
[package.metadata.docs.rs]
63+
all-features = true
64+
rustdoc-args = ["--cfg", "docsrs"]
65+
66+
[package.metadata.cargo_check_external_types]
67+
allowed_external_types = ["rustls_pki_types::*"]

0 commit comments

Comments
 (0)