diff options
author | Aria Shrimpton <me@aria.rip> | 2024-01-19 23:42:38 +0000 |
---|---|---|
committer | Aria Shrimpton <me@aria.rip> | 2024-01-19 23:42:38 +0000 |
commit | 8ab9e6779d714aa3f9bfc769a36a9eae7d61c0f9 (patch) | |
tree | 550407157e63e1b5a1e8e582a7a9ddf4b723284b /src/tests/example_stack | |
parent | 0490d79107fd2b732054c2c59d534a8cf5026011 (diff) |
feat(cli): compare real results against chosen assignment
Diffstat (limited to 'src/tests/example_stack')
-rw-r--r-- | src/tests/example_stack/Cargo.toml | 5 | ||||
-rw-r--r-- | src/tests/example_stack/benches/do_stuff.rs | 12 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/tests/example_stack/Cargo.toml b/src/tests/example_stack/Cargo.toml index 3e3e617..55e4338 100644 --- a/src/tests/example_stack/Cargo.toml +++ b/src/tests/example_stack/Cargo.toml @@ -8,6 +8,9 @@ edition = "2021" [dependencies] primrose-library = { path = "../../crates/library" } +[dev-dependencies] +criterion = { workspace = true } + [[bench]] name = "do_stuff" -harness = false
\ No newline at end of file +harness = false diff --git a/src/tests/example_stack/benches/do_stuff.rs b/src/tests/example_stack/benches/do_stuff.rs index 69d50d5..c7e2e23 100644 --- a/src/tests/example_stack/benches/do_stuff.rs +++ b/src/tests/example_stack/benches/do_stuff.rs @@ -1,6 +1,8 @@ -fn main() { - // TODO: some actual benchmarking, not just a random loop - for _ in 0..20 { - example_stack::do_something(); - } +use criterion::{criterion_group, criterion_main, Criterion}; + +fn run_benches(c: &mut Criterion) { + c.bench_function("do_something", |b| b.iter(|| example_stack::do_something())); } + +criterion_group!(benches, run_benches); +criterion_main!(benches); |