extern crate libc; use std::mem::MaybeUninit; fn main() { let mut steps = 0; loop { steps += 1; if steps < 100000 { continue; } steps = 0; let mut usage = MaybeUninit::::uninit(); unsafe { assert_eq!(libc::getrusage(libc::RUSAGE_THREAD, usage.as_mut_ptr()), 0); } let usage = unsafe { usage.assume_init() }.ru_utime; let us = usage.tv_sec * 1_000_000 + usage.tv_usec; if us >= 500_000 { break; } } }