From 947da9820855181fc07dc06fe14416a046225487 Mon Sep 17 00:00:00 2001 From: Aria Date: Thu, 30 Nov 2023 17:49:04 +0000 Subject: test: add benchmark for example_stack (for testing) --- src/tests/example_stack/Cargo.toml | 6 +++++- src/tests/example_stack/benches/do_stuff.rs | 6 ++++++ src/tests/example_stack/src/lib.rs | 12 ++++++++++++ src/tests/example_stack/src/main.rs | 12 ------------ 4 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 src/tests/example_stack/benches/do_stuff.rs create mode 100644 src/tests/example_stack/src/lib.rs delete mode 100644 src/tests/example_stack/src/main.rs diff --git a/src/tests/example_stack/Cargo.toml b/src/tests/example_stack/Cargo.toml index 9827bef..3e3e617 100644 --- a/src/tests/example_stack/Cargo.toml +++ b/src/tests/example_stack/Cargo.toml @@ -6,4 +6,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -primrose-library = { path = "../../crates/library" } \ No newline at end of file +primrose-library = { path = "../../crates/library" } + +[[bench]] +name = "do_stuff" +harness = false \ No newline at end of file diff --git a/src/tests/example_stack/benches/do_stuff.rs b/src/tests/example_stack/benches/do_stuff.rs new file mode 100644 index 0000000..69d50d5 --- /dev/null +++ b/src/tests/example_stack/benches/do_stuff.rs @@ -0,0 +1,6 @@ +fn main() { + // TODO: some actual benchmarking, not just a random loop + for _ in 0..20 { + example_stack::do_something(); + } +} diff --git a/src/tests/example_stack/src/lib.rs b/src/tests/example_stack/src/lib.rs new file mode 100644 index 0000000..d8e95f3 --- /dev/null +++ b/src/tests/example_stack/src/lib.rs @@ -0,0 +1,12 @@ +mod types; +use types::*; + +pub fn do_something() { + let mut c = StackCon::::default(); + for x in 0..10 { + c.insert(x); + c.insert(x); + //c.first(); + } + assert_eq!(c.len(), 20); +} diff --git a/src/tests/example_stack/src/main.rs b/src/tests/example_stack/src/main.rs deleted file mode 100644 index d36e683..0000000 --- a/src/tests/example_stack/src/main.rs +++ /dev/null @@ -1,12 +0,0 @@ -mod types; -use types::*; - -fn main() { - let mut c = StackCon::::default(); - for x in 0..10 { - c.insert(x); - c.insert(x); - //c.first(); - } - assert_eq!(c.len(), 20); -} -- cgit v1.2.3