cf-mach 0.2.1

Network quality measurement CLI for latency, throughput, packet loss, and responsiveness
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Copyright (c) 2023-2024 Cloudflare, Inc.
// Licensed under the BSD-3-Clause license found in the LICENSE file or at https://opensource.org/licenses/BSD-3-Clause

/// Converts f64 seconds to f64 ms rounded to 3 decimals.
pub fn pretty_secs_to_ms(secs: f64) -> f64 {
    (secs * 1_000_000.0).trunc() / 1_000.0
}

/// Rounds f64 ms to 3 decimals.
pub fn pretty_ms(ms: f64) -> f64 {
    (ms * 1_000.0).trunc() / 1_000.0
}

/// Round f64 seconds to 3 decimals.
pub fn pretty_secs(secs: f64) -> f64 {
    (secs * 1_000.0).trunc() / 1_000.0
}