diff options
| author | Fuwn <[email protected]> | 2021-07-03 13:11:58 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-07-03 13:11:58 -0700 |
| commit | 207fe6b3c8c3f4ceacc95cc33279e7b7b6524b92 (patch) | |
| tree | 14c703f882ac151a992bd691b38ed11136d2eb84 /benches | |
| parent | style(crates): minor changes to crate descriptions (diff) | |
| download | whirl-207fe6b3c8c3f4ceacc95cc33279e7b7b6524b92.tar.xz whirl-207fe6b3c8c3f4ceacc95cc33279e7b7b6524b92.zip | |
test(whirl_common): add criterion benchmarks
Diffstat (limited to 'benches')
| -rw-r--r-- | benches/whirl_common_criterion.rs | 23 | ||||
| -rw-r--r-- | benches/whirl_common_iai.rs (renamed from benches/whirl_common.rs) | 0 |
2 files changed, 23 insertions, 0 deletions
diff --git a/benches/whirl_common_criterion.rs b/benches/whirl_common_criterion.rs new file mode 100644 index 0000000..b004530 --- /dev/null +++ b/benches/whirl_common_criterion.rs @@ -0,0 +1,23 @@ +// Copyright (C) 2021-2021 The Whirlsplash Collective +// SPDX-License-Identifier: GPL-3.0-only + +use criterion::{criterion_group, criterion_main, Criterion}; + +fn criterion_benchmark_sort_vec_alphabetically(c: &mut Criterion) { + c.bench_function("sort vec alphabetically", |b| { + b.iter(|| whirl_common::sort::vec_alphabetically(&mut vec!["a", "c", "d", "b"])) + }); +} + +fn criterion_benchmark_system_seconds_to_hrtime(c: &mut Criterion) { + c.bench_function("system seconds to human readable time", |b| { + b.iter(|| whirl_common::system::seconds_to_hrtime(1623058677)) + }); +} + +criterion_group!( + benches, + criterion_benchmark_sort_vec_alphabetically, + criterion_benchmark_system_seconds_to_hrtime, +); +criterion_main!(benches); diff --git a/benches/whirl_common.rs b/benches/whirl_common_iai.rs index 025c719..025c719 100644 --- a/benches/whirl_common.rs +++ b/benches/whirl_common_iai.rs |