From eaab5002bc9743bf97e9d9427fc775152d109a9c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Sat, 21 May 2016 09:59:33 -0400 Subject: [PATCH] lib & contrib: update users of Clock MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- contrib/tinks/src/game/framework.nit | 2 +- lib/gamnit/limit_fps.nit | 6 +++--- lib/mnit/mnit_fps.nit | 6 +++--- lib/performance_analysis.nit | 7 ++----- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/contrib/tinks/src/game/framework.nit b/contrib/tinks/src/game/framework.nit index 49c74b0..9472da6 100644 --- a/contrib/tinks/src/game/framework.nit +++ b/contrib/tinks/src/game/framework.nit @@ -41,7 +41,7 @@ class TGame var dt = clock.lapse tick += 1 - var turn = new TTurn(self, tick, dt.to_f, dt.millisec) + var turn = new TTurn(self, tick, dt, ((dt-dt.floor)*1000.0).to_i) return turn end diff --git a/lib/gamnit/limit_fps.nit b/lib/gamnit/limit_fps.nit index f16609f..896f07f 100644 --- a/lib/gamnit/limit_fps.nit +++ b/lib/gamnit/limit_fps.nit @@ -47,7 +47,7 @@ redef class App private var frame_count = 0 # Deadline used to compute `current_fps` - private var frame_count_deadline = 5 + private var frame_count_deadline = 5.0 # Check and sleep to maintain a frame-rate bellow `maximum_fps` # @@ -55,12 +55,12 @@ redef class App # Is automatically called at the end of `full_frame`. fun limit_fps do - var t = clock.total.sec + var t = clock.total if t >= frame_count_deadline then var cfps = frame_count.to_f / 5.0 self.current_fps = cfps frame_count = 0 - frame_count_deadline = t + 5 + frame_count_deadline = t + 5.0 end frame_count += 1 diff --git a/lib/mnit/mnit_fps.nit b/lib/mnit/mnit_fps.nit index 3841bc6..f4abd92 100644 --- a/lib/mnit/mnit_fps.nit +++ b/lib/mnit/mnit_fps.nit @@ -44,19 +44,19 @@ redef class App private var frame_count = 0 # Deadline used to compute `current_fps` - private var frame_count_deadline = 0 + private var frame_count_deadline = 0.0 # Check and sleep to maitain a frame-rate bellow `maximum_fps` # Also periodically uptate `current_fps` # Is automatically called at the end of `full_frame`. fun limit_fps do - var t = clock.total.sec + var t = clock.total if t >= frame_count_deadline then var cfps = frame_count.to_f / 5.0 self.current_fps = cfps frame_count = 0 - frame_count_deadline = t + 5 + frame_count_deadline = t + 5.0 end frame_count += 1 diff --git a/lib/performance_analysis.nit b/lib/performance_analysis.nit index 4763061..b9e436a 100644 --- a/lib/performance_analysis.nit +++ b/lib/performance_analysis.nit @@ -122,11 +122,8 @@ class PerfEntry # Total execution time of this event var sum = 0.0 - # Register a new event execution time with a `Timespec` - fun add(lapse: Timespec) do add_float lapse.to_f - - # Register a new event execution time in seconds using a `Float` - fun add_float(time: Float) + # Register a new event execution time in seconds + fun add(time: Float) do if time.to_f < min.to_f or count == 0 then min = time if time.to_f > max.to_f then max = time -- 1.7.9.5