rust version: fix calculation of loops/sec and solutions/sec

This commit is contained in:
ddidderr 2022-08-26 08:38:05 +02:00
parent bc8cf33fd6
commit 198084206b
Signed by: ddidderr
GPG Key ID: 3841F1C27E6F0E14

View File

@ -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;