diff options
| author | Eric Holk <eholk@mozilla.com> | 2011-06-28 17:58:44 -0700 |
|---|---|---|
| committer | Eric Holk <eholk@mozilla.com> | 2011-06-30 11:32:10 -0700 |
| commit | b4a145e60f4bbc90dc780239cc49c024b9f52ca8 (patch) | |
| tree | 020734b92aa7fea2269b3915d45d1d9730c4192c /src/lib | |
| parent | 441c7e06109772f7ff942682fb6d0a7535f03666 (diff) | |
| download | rust-b4a145e60f4bbc90dc780239cc49c024b9f52ca8.tar.gz rust-b4a145e60f4bbc90dc780239cc49c024b9f52ca8.zip | |
Added a nanosecond timer to time.rs, support for some floating point casts, and a commandline-driven mode for pfib.rs
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/time.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/lib/time.rs b/src/lib/time.rs index 65d02616294..d2c61b74e98 100644 --- a/src/lib/time.rs +++ b/src/lib/time.rs @@ -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); -} \ No newline at end of file +} + +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.; +} |
