From 66e51f9a553b3066c7490904b9b71540cfa599c0 Mon Sep 17 00:00:00 2001 From: Chengcheng Jin Date: Thu, 8 Aug 2024 17:27:07 +0000 Subject: [PATCH] [oap ] Fix unit test MicrosecondTimer is too large to track --- velox/exec/SpillFile.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/velox/exec/SpillFile.cpp b/velox/exec/SpillFile.cpp index f014a4d5f0ae..c792e9d526cc 100644 --- a/velox/exec/SpillFile.cpp +++ b/velox/exec/SpillFile.cpp @@ -66,11 +66,16 @@ void SpillInputStream::next(bool /*throwIfPastEnd*/) { uint64_t readTimeUs{0}; if (readaWait_.valid()) { { - MicrosecondTimer timer{&readTimeUs}; + // TODO: it is ns not us, wait to change, just make unit test fine, wait + // PR to change, MicrosecondTimer is too big. + auto start = std::chrono::steady_clock::now(); readBytes = std::move(readaWait_) .via(&folly::QueuedImmediateExecutor::instance()) .wait() .value(); + auto duration = std::chrono::duration_cast( + std::chrono::steady_clock::now() - start); + readTimeUs = duration.count(); VELOX_CHECK(!readaWait_.valid()); } VELOX_CHECK_LT(0, readBytes, "Reading past end of spill file"); @@ -79,8 +84,11 @@ void SpillInputStream::next(bool /*throwIfPastEnd*/) { readBytes = readSize(); VELOX_CHECK_LT(0, readBytes, "Reading past end of spill file"); { - MicrosecondTimer timer{&readTimeUs}; + auto start = std::chrono::steady_clock::now(); file_->pread(offset_, readBytes, buffer()->asMutable()); + auto duration = std::chrono::duration_cast( + std::chrono::steady_clock::now() - start); + readTimeUs = duration.count(); } } setRange({buffer()->asMutable(), readBytes, 0});