From cad772f0b400e7348b0c8a184d3875abea5a5ffe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Fri, 12 Jun 2015 17:12:55 -0400 Subject: [PATCH] lib/realtime: intro `Clock::peek_lapse` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/realtime.nit | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/realtime.nit b/lib/realtime.nit index 8cfa4da..523f63e 100644 --- a/lib/realtime.nit +++ b/lib/realtime.nit @@ -156,4 +156,15 @@ class Clock time_at_last_lapse = nt return dt end + + # Seconds since the last call to `lapse`, without resetting the lapse counter + fun peek_lapse: Float + do + var nt = new Timespec.monotonic_now + var dt = nt - time_at_last_lapse + var r = dt.to_f + nt.free + dt.free + return r + end end -- 1.7.9.5