aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-06-07 08:31:32 +0000
committerFuwn <[email protected]>2021-06-07 08:31:32 +0000
commitebfe72081182e1f4a176170a9ab111397356ffa8 (patch)
treefd36170de0ddcc14c4796a6384cc6f56142a546b
parentchore(manifest): update version (diff)
downloadnitrous-ebfe72081182e1f4a176170a9ab111397356ffa8.tar.xz
nitrous-ebfe72081182e1f4a176170a9ab111397356ffa8.zip
ci: create benchmark
-rw-r--r--Cargo.toml7
-rw-r--r--benches/bench.rs21
2 files changed, 28 insertions, 0 deletions
diff --git a/Cargo.toml b/Cargo.toml
index c2a6006..4d39e0b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,6 +14,10 @@ publish = false
lto = "fat"
codegen-units = 1
+[[bench]]
+name = "bench"
+harness = false
+
[dependencies]
# CLI
structopt = "0.3.21"
@@ -39,3 +43,6 @@ mimalloc = { version = "0.1.25", default-features = false }
[target.'cfg(target_family = "unix")'.dependencies]
jemallocator = "0.3.2"
+
+[dev-dependencies]
+criterion = "0.3.4"
diff --git a/benches/bench.rs b/benches/bench.rs
new file mode 100644
index 0000000..5a432c3
--- /dev/null
+++ b/benches/bench.rs
@@ -0,0 +1,21 @@
+// Copyleft (ɔ) 2021-2021 Fuwn
+// SPDX-License-Identifier: GPL-3.0-only
+
+#[macro_use]
+extern crate criterion;
+
+use rand::Rng;
+use criterion::Criterion;
+
+fn bench_generate(c: &mut Criterion) {
+ c.bench_function("generate", |b| b.iter(|| {
+ rand::thread_rng()
+ .sample_iter(rand::distributions::Alphanumeric)
+ .take(16)
+ .map(char::from)
+ .collect::<String>()
+ }));
+}
+
+criterion_group!(benches, bench_generate);
+criterion_main!(benches);