From 198084206b7044bf7b977f12d7259ceb9d31ad3a Mon Sep 17 00:00:00 2001 From: ddidderr Date: Fri, 26 Aug 2022 08:38:05 +0200 Subject: [PATCH] rust version: fix calculation of loops/sec and solutions/sec --- src/main.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0684013..43a9af3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -139,16 +139,20 @@ impl SField { loop_count += 1; const MILLIS_PER_SEC: u128 = 1_000; const UPDATE_DELAY_MS: u128 = 80; - if now.elapsed().as_millis() >= UPDATE_DELAY_MS { + if loop_count % 1000 == 0 { + let elapsed_ms = now.elapsed().as_millis(); + if elapsed_ms <= UPDATE_DELAY_MS { + continue; + } self.print_clear(); self.print(); println!( "{} loops/sec", - (loop_count - last_loop_count) * (MILLIS_PER_SEC / UPDATE_DELAY_MS) + (loop_count - last_loop_count) * (MILLIS_PER_SEC / elapsed_ms) ); println!( "{} solutions/sec", - (num_solutions - last_num_solutions) * (MILLIS_PER_SEC / UPDATE_DELAY_MS) + (num_solutions - last_num_solutions) * (MILLIS_PER_SEC / elapsed_ms) ); last_loop_count = loop_count; last_num_solutions = num_solutions;