From 490312bf57dcc1560633f03ee1f63fce94f85dae Mon Sep 17 00:00:00 2001 From: Zhenchi Date: Wed, 10 Jan 2024 17:41:52 +0800 Subject: [PATCH] fix: unstable time record test (#3131) Signed-off-by: Zhenchi --- src/mito2/src/sst/index/creator/statistics.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/mito2/src/sst/index/creator/statistics.rs b/src/mito2/src/sst/index/creator/statistics.rs index e4f30db7a9..65d01547e9 100644 --- a/src/mito2/src/sst/index/creator/statistics.rs +++ b/src/mito2/src/sst/index/creator/statistics.rs @@ -144,12 +144,25 @@ mod tests { let mut guard = stats.record_update(); guard.inc_byte_count(100); guard.inc_row_count(10); + + let now = Instant::now(); + while now.elapsed().is_zero() { + // busy loop + } } { let _guard = stats.record_finish(); + let now = Instant::now(); + while now.elapsed().is_zero() { + // busy loop + } } { let _guard = stats.record_cleanup(); + let now = Instant::now(); + while now.elapsed().is_zero() { + // busy loop + } } assert_eq!(stats.row_count(), 10); assert_eq!(stats.byte_count(), 100);