diff options
| author | Fuwn <[email protected]> | 2021-07-03 13:15:37 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-07-03 13:15:37 +0000 |
| commit | 6153a3e5ae3eff1c73ba47c310717d879b4ca1c5 (patch) | |
| tree | e09da20c4b0ed1d2f218d6dfac21496f787ba4c1 | |
| parent | test(whirl_common): add criterion benchmarks (diff) | |
| download | archived-whirl-6153a3e5ae3eff1c73ba47c310717d879b4ca1c5.tar.xz archived-whirl-6153a3e5ae3eff1c73ba47c310717d879b4ca1c5.zip | |
refactor(whirl_common): rename `seconds_to_hrtime` to `unixts_to_hrtime`
| -rw-r--r-- | benches/whirl_common_criterion.rs | 8 | ||||
| -rw-r--r-- | benches/whirl_common_iai.rs | 6 | ||||
| -rw-r--r-- | crates/whirl_api/src/routes/stats/mod.rs | 2 | ||||
| -rw-r--r-- | crates/whirl_common/src/system.rs | 2 | ||||
| -rw-r--r-- | crates/whirl_common/tests/test.rs | 2 |
5 files changed, 10 insertions, 10 deletions
diff --git a/benches/whirl_common_criterion.rs b/benches/whirl_common_criterion.rs index b004530..b73060e 100644 --- a/benches/whirl_common_criterion.rs +++ b/benches/whirl_common_criterion.rs @@ -9,15 +9,15 @@ fn criterion_benchmark_sort_vec_alphabetically(c: &mut Criterion) { }); } -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)) +fn criterion_benchmark_system_unixts_to_hrtime(c: &mut Criterion) { + c.bench_function("system unix timestamp to human readable time", |b| { + b.iter(|| whirl_common::system::unixts_to_hrtime(1623058677)) }); } criterion_group!( benches, criterion_benchmark_sort_vec_alphabetically, - criterion_benchmark_system_seconds_to_hrtime, + criterion_benchmark_system_unixts_to_hrtime, ); criterion_main!(benches); diff --git a/benches/whirl_common_iai.rs b/benches/whirl_common_iai.rs index 025c719..1909363 100644 --- a/benches/whirl_common_iai.rs +++ b/benches/whirl_common_iai.rs @@ -5,11 +5,11 @@ fn iai_benchmark_sort_vec_alphabetically() { whirl_common::sort::vec_alphabetically(&mut vec!["a", "c", "d", "b"]) } -fn iai_benchmark_system_seconds_to_hrtime() -> String { - whirl_common::system::seconds_to_hrtime(1623058677) +fn iai_benchmark_system_unixts_to_hrtime() -> String { + whirl_common::system::unixts_to_hrtime(1623058677) } iai::main!( iai_benchmark_sort_vec_alphabetically, - iai_benchmark_system_seconds_to_hrtime + iai_benchmark_system_unixts_to_hrtime ); diff --git a/crates/whirl_api/src/routes/stats/mod.rs b/crates/whirl_api/src/routes/stats/mod.rs index d5efc91..5ec5eee 100644 --- a/crates/whirl_api/src/routes/stats/mod.rs +++ b/crates/whirl_api/src/routes/stats/mod.rs @@ -23,7 +23,7 @@ pub fn statistics() -> HttpResponse { system: StatisticsSystem { os_type: sys.name().unwrap(), release: sys.kernel_version().unwrap(), - uptime: whirl_common::system::seconds_to_hrtime(usize::try_from(sys.uptime()).unwrap()), + uptime: whirl_common::system::unixts_to_hrtime(usize::try_from(sys.uptime()).unwrap()), }, process: StatisticsProcess { // (process.cpu_usage() * 100.0).round() / 100.0 diff --git a/crates/whirl_common/src/system.rs b/crates/whirl_common/src/system.rs index c4b203c..72f6a33 100644 --- a/crates/whirl_common/src/system.rs +++ b/crates/whirl_common/src/system.rs @@ -18,7 +18,7 @@ fn make_parts(t: usize, steps: &[usize], mut accum: Vec<usize>) -> Vec<usize> { /// Convert a Unix (Epoch) Timestamp to a human-readable format. #[must_use] -pub fn seconds_to_hrtime(seconds: usize) -> String { +pub fn unixts_to_hrtime(seconds: usize) -> String { let word = ["week", "day", "hour", "min", "sec"]; make_parts(seconds, &[WEEK, DAY, HOUR, MIN, 1], Vec::new()) diff --git a/crates/whirl_common/tests/test.rs b/crates/whirl_common/tests/test.rs index 6727948..d786fa4 100644 --- a/crates/whirl_common/tests/test.rs +++ b/crates/whirl_common/tests/test.rs @@ -16,6 +16,6 @@ fn vec_alphabetically() { fn seconds_to_hrtime() { assert_eq!( "125 weeks, 14 days, 9 hours, 37 mins, 57 secs", - whirl_common::system::seconds_to_hrtime(1623058677), + whirl_common::system::unixts_to_hrtime(1623058677), ); } |