os_clock
Access various operating system clocks (such as per-thread CPU Time, system clock, monotomic, etc) on Unix-family systems.
use ;
let clock = cpu_clock_for_current_thread;
clock.get_time;
Notably, a clock for the CPU time of one thread can be accessed from another thread:
let clock = cpu_clock_for_current_thread.unwrap;
loop
spawn
.join
.unwrap;
Compatibility
Works on recent iOS, Mac, as well as Unix-family systems with a pthread.h
that defines pthread_getcpuclockid
(most modern Linux).