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 | |
parent | 0490d79107fd2b732054c2c59d534a8cf5026011 (diff) |
feat(cli): compare real results against chosen assignment
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/Cargo.toml | 5 | ||||
-rw-r--r-- | src/tests/example_stack/Cargo.toml | 5 | ||||
-rw-r--r-- | src/tests/example_stack/benches/do_stuff.rs | 12 |
3 files changed, 15 insertions, 7 deletions
diff --git a/src/tests/Cargo.toml b/src/tests/Cargo.toml index d4d9ab2..b40694f 100644 --- a/src/tests/Cargo.toml +++ b/src/tests/Cargo.toml @@ -2,4 +2,7 @@ resolver = "2" members = [ "example_stack", -]
\ No newline at end of file +] + +[workspace.dependencies] +criterion = "0.3" 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); |