Added a nanosecond timer to time.rs, support for some floating point casts, and a commandline-driven mode for pfib.rs
This commit is contained in:
parent
441c7e0610
commit
b4a145e60f
7 changed files with 95 additions and 33 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
native "rust" mod rustrt {
|
||||
fn get_time(&mutable u32 sec, &mutable u32 usec);
|
||||
fn nano_time(&mutable u64 ns);
|
||||
}
|
||||
|
||||
type timeval = rec(u32 sec, u32 usec);
|
||||
|
|
@ -11,4 +12,14 @@ fn get_time() -> timeval {
|
|||
auto usec = 0u32;
|
||||
rustrt::get_time(sec, usec);
|
||||
ret rec(sec=sec, usec=usec);
|
||||
}
|
||||
}
|
||||
|
||||
fn precise_time_ns() -> u64 {
|
||||
auto ns = 0u64;
|
||||
rustrt::nano_time(ns);
|
||||
ret ns;
|
||||
}
|
||||
|
||||
fn precise_time_s() -> float {
|
||||
ret (precise_time_ns() as float) / 1000000000.;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue