From 84881fd9e14571c796459a8e68479b7fa26ded23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karolis=20Gudi=C5=A1kis?= Date: Mon, 19 Feb 2024 16:49:13 +0200 Subject: [PATCH] fix: Fix dummy sink performance output when count of op is not divisible by 1000 --- dozer-cli/src/pipeline/dummy_sink.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dozer-cli/src/pipeline/dummy_sink.rs b/dozer-cli/src/pipeline/dummy_sink.rs index 66a3ccb0b7..50eabfee21 100644 --- a/dozer-cli/src/pipeline/dummy_sink.rs +++ b/dozer-cli/src/pipeline/dummy_sink.rs @@ -55,6 +55,7 @@ impl SinkFactory for DummySinkFactory { stop_after: std::env::var("STOP_AFTER").map_or(None, |s| s.parse().ok()), first_received: None, total_latency: 0, + previous_op_count: 0, })) } @@ -69,6 +70,7 @@ struct DummySink { inserted_at_index: Option, count: usize, previous_started: Instant, + previous_op_count: usize, first_received: Option, stop_after: Option, total_latency: u64, @@ -79,16 +81,18 @@ impl Sink for DummySink { if self.count == 0 { self.first_received = Some(Instant::now()); } - if self.count % 1000 == 0 { + let diff = self.count - self.previous_op_count; + if diff > 1000 { if self.count > 0 { info!( "Rate: {:.0} op/s, Processed {} records. Elapsed {:?}", - 1000.0 / self.previous_started.elapsed().as_secs_f64(), + diff as f64 / self.previous_started.elapsed().as_secs_f64(), self.count, self.previous_started.elapsed(), ); } self.previous_started = Instant::now(); + self.previous_op_count = self.count; } self.count += match op.op {