sysutils: fix dd
divide by zero
This commit is contained in:
parent
c0d34d2c56
commit
b60cc4df52
@ -12,9 +12,9 @@ use yggdrasil_abi::{error::Error, time::SystemTime};
|
||||
|
||||
use crate::time::monotonic_time;
|
||||
|
||||
// 1..32ms, tick every 1ms
|
||||
static SHORT_TERM_SLEEPS: IrqSafeSpinlock<TimerWheel<32>> =
|
||||
IrqSafeSpinlock::new(TimerWheel::new(0, 1));
|
||||
// 2..32ms, tick every 2ms
|
||||
static SHORT_TERM_SLEEPS: IrqSafeSpinlock<TimerWheel<16>> =
|
||||
IrqSafeSpinlock::new(TimerWheel::new(0, 2));
|
||||
// 32ms..288ms, tick every 8ms
|
||||
static LONG_TERM_SLEEPS: IrqSafeSpinlock<TimerWheel<32>> =
|
||||
IrqSafeSpinlock::new(TimerWheel::new(4, 8));
|
||||
@ -69,7 +69,7 @@ impl<const STEPS: usize> TimerWheel<STEPS> {
|
||||
}
|
||||
|
||||
fn register_timeout(duration: Duration, waker: &Waker) {
|
||||
let nticks = duration.as_millis().min(288) as u64;
|
||||
let nticks = duration.as_millis().min(288).max(2) as u64;
|
||||
|
||||
if nticks < 32 {
|
||||
SHORT_TERM_SLEEPS.lock().wake_after(nticks, waker);
|
||||
|
@ -68,8 +68,9 @@ fn dump_block(offset: u64, data: &[u8]) {
|
||||
|
||||
fn print_throughput(duration: Duration, bytes_read: usize) {
|
||||
let read_total = humansize::format_size(bytes_read as u64, humansize::FormatSizeOptions::default());
|
||||
let read_per_second = bytes_read as u64 / duration.as_secs();
|
||||
let read_speed = humansize::format_size(read_per_second, humansize::FormatSizeOptions::default());
|
||||
let ms = duration.as_millis() as u64;
|
||||
let read_per_ms = bytes_read as u64 / ms;
|
||||
let read_speed = humansize::format_size(read_per_ms * 1000, humansize::FormatSizeOptions::default());
|
||||
|
||||
eprintln!("{read_speed}/s ({read_total} in {duration:?})");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user