mirror of
https://github.com/NotAShelf/microfetch.git
synced 2026-04-13 13:23:52 +00:00
meta: move benchmarks to dedicated crate
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I753245e75da3a995c622a2c73f77bcb26a6a6964
This commit is contained in:
parent
23e994a8fb
commit
77d9c725c7
5 changed files with 112 additions and 10 deletions
21
crates/benchmarks/Cargo.toml
Normal file
21
crates/benchmarks/Cargo.toml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
[package]
|
||||
name = "microfetch-bench"
|
||||
description = "Benchmarks for microfetch"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
authors.workspace = true
|
||||
rust-version.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
criterion.workspace = true
|
||||
criterion-cycles-per-byte.workspace = true
|
||||
microfetch-lib.workspace = true
|
||||
|
||||
[[bench]]
|
||||
harness = false
|
||||
name = "microfetch"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
33
crates/benchmarks/benches/microfetch.rs
Normal file
33
crates/benchmarks/benches/microfetch.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
use criterion::{Criterion, criterion_group, criterion_main};
|
||||
use microfetch_lib::{
|
||||
UtsName,
|
||||
colors::print_dots,
|
||||
desktop::get_desktop_info,
|
||||
release::{get_os_pretty_name, get_system_info},
|
||||
system::{
|
||||
get_memory_usage,
|
||||
get_root_disk_usage,
|
||||
get_shell,
|
||||
get_username_and_hostname,
|
||||
},
|
||||
uptime::get_current,
|
||||
};
|
||||
|
||||
fn main_benchmark(c: &mut Criterion) {
|
||||
let utsname = UtsName::uname().expect("Failed to get uname");
|
||||
c.bench_function("user_info", |b| {
|
||||
b.iter(|| get_username_and_hostname(&utsname));
|
||||
});
|
||||
c.bench_function("os_name", |b| b.iter(get_os_pretty_name));
|
||||
c.bench_function("kernel_version", |b| b.iter(|| get_system_info(&utsname)));
|
||||
c.bench_function("shell", |b| b.iter(get_shell));
|
||||
|
||||
c.bench_function("desktop", |b| b.iter(get_desktop_info));
|
||||
c.bench_function("uptime", |b| b.iter(get_current));
|
||||
c.bench_function("memory_usage", |b| b.iter(get_memory_usage));
|
||||
c.bench_function("storage", |b| b.iter(get_root_disk_usage));
|
||||
c.bench_function("colors", |b| b.iter(print_dots));
|
||||
}
|
||||
|
||||
criterion_group!(benches, main_benchmark);
|
||||
criterion_main!(benches);
|
||||
Loading…
Add table
Add a link
Reference in a new issue