aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-02-02 10:24:52 +0000
committerfanquake <fanquake@gmail.com>2023-02-02 10:30:29 +0000
commit9dc50a5a0788fa07fa67e9ffa1457e53aa9a0e53 (patch)
treeca7b5193dfc2ed8e7a14cdcd4040a7268c40caff /src/test
parent102645280b945a0fbbbe67f8b55f1fc6b16b9b89 (diff)
parentfad7af700e3f57d16631e27fbe2fd7aaa6c9a950 (diff)
Merge bitcoin/bitcoin#27005: util: Use steady clock for logging timer
fad7af700e3f57d16631e27fbe2fd7aaa6c9a950 Use steady clock for logging timer (MarcoFalke) Pull request description: The logging timer has many issues: * The underlying clock is mockable, meaning that benchmarks are useless when mocktime was set at the beginning or end of the benchmark. * The underlying clock is not monotonic, meaning that benchmarks are useless when the system time was changed during the benchmark. Fix all issues in this patch. ACKs for top commit: stickies-v: Approach ACK fad7af700e3f57d16631e27fbe2fd7aaa6c9a950 john-moffett: ACK fad7af700e3f57d16631e27fbe2fd7aaa6c9a950 Tree-SHA512: bec8da0f338ed4611e1807937575e1b2afda25139d88015b1c29fa7d13946fbfbc4ee589b576c0508d505df5e5fafafcbc07d63ce4bab4b01475260d9d5d2107
Diffstat (limited to 'src/test')
-rw-r--r--src/test/logging_tests.cpp15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/test/logging_tests.cpp b/src/test/logging_tests.cpp
index 022e33f99d..beb9398c74 100644
--- a/src/test/logging_tests.cpp
+++ b/src/test/logging_tests.cpp
@@ -75,20 +75,9 @@ struct LogSetup : public BasicTestingSetup {
BOOST_AUTO_TEST_CASE(logging_timer)
{
- SetMockTime(1);
auto micro_timer = BCLog::Timer<std::chrono::microseconds>("tests", "end_msg");
- SetMockTime(2);
- BOOST_CHECK_EQUAL(micro_timer.LogMsg("test micros"), "tests: test micros (1000000μs)");
-
- SetMockTime(1);
- auto ms_timer = BCLog::Timer<std::chrono::milliseconds>("tests", "end_msg");
- SetMockTime(2);
- BOOST_CHECK_EQUAL(ms_timer.LogMsg("test ms"), "tests: test ms (1000.00ms)");
-
- SetMockTime(1);
- auto sec_timer = BCLog::Timer<std::chrono::seconds>("tests", "end_msg");
- SetMockTime(2);
- BOOST_CHECK_EQUAL(sec_timer.LogMsg("test secs"), "tests: test secs (1.00s)");
+ const std::string_view result_prefix{"tests: msg ("};
+ BOOST_CHECK_EQUAL(micro_timer.LogMsg("msg").substr(0, result_prefix.size()), result_prefix);
}
BOOST_FIXTURE_TEST_CASE(logging_LogPrintf_, LogSetup)