aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2025-02-07 15:40:57 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2025-02-07 15:54:34 +0300
commit7070f20922c00df17bb1cbfeb05ff15281163b3d (patch)
tree95e5bc341c30e62a4389453e57f2614ab60e0e99
parent348a25fa51c647410f68cdc574431c223046ac8a (diff)
downloadydb-7070f20922c00df17bb1cbfeb05ff15281163b3d.tar.gz
Intermediate changes
commit_hash:21bc37ea2a290cb645c95fe2c94882484c7001a4
-rw-r--r--util/datetime/benchmark/gmtime_r/main.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/util/datetime/benchmark/gmtime_r/main.cpp b/util/datetime/benchmark/gmtime_r/main.cpp
index a3356d780c3..705f81006dd 100644
--- a/util/datetime/benchmark/gmtime_r/main.cpp
+++ b/util/datetime/benchmark/gmtime_r/main.cpp
@@ -34,11 +34,30 @@ void BM_GmTimeRRandom(benchmark::State& state, TDuration window) {
}
}
+void BM_gmtime_r_Random(benchmark::State& state, TDuration window) {
+ time_t now = TInstant::Now().TimeT();
+ struct tm buf {};
+
+ TFastRng<ui32> rng(2);
+ const size_t range = window.Seconds();
+ for (auto _ : state) {
+ size_t offset = rng.GenRand() % range;
+ time_t v = now - offset;
+ Y_DO_NOT_OPTIMIZE_AWAY(gmtime_r(&v, &buf));
+ }
+}
+
BENCHMARK(BM_GmTimeR);
BENCHMARK(BM_gmtime_r);
BENCHMARK_CAPTURE(BM_GmTimeRRandom, last_hour, TDuration::Hours(1));
+BENCHMARK_CAPTURE(BM_gmtime_r_Random, last_hour, TDuration::Hours(1));
BENCHMARK_CAPTURE(BM_GmTimeRRandom, last_day, TDuration::Days(1));
-BENCHMARK_CAPTURE(BM_GmTimeRRandom, last_mount, TDuration::Days(31));
+BENCHMARK_CAPTURE(BM_gmtime_r_Random, last_day, TDuration::Days(1));
+BENCHMARK_CAPTURE(BM_GmTimeRRandom, last_month, TDuration::Days(31));
+BENCHMARK_CAPTURE(BM_gmtime_r_Random, last_month, TDuration::Days(31));
BENCHMARK_CAPTURE(BM_GmTimeRRandom, last_year, TDuration::Days(365));
+BENCHMARK_CAPTURE(BM_gmtime_r_Random, last_year, TDuration::Days(365));
BENCHMARK_CAPTURE(BM_GmTimeRRandom, last_decade, TDuration::Days(3653));
+BENCHMARK_CAPTURE(BM_gmtime_r_Random, last_decade, TDuration::Days(3653));
BENCHMARK_CAPTURE(BM_GmTimeRRandom, last_half_centry, TDuration::Days(18262));
+BENCHMARK_CAPTURE(BM_gmtime_r_Random, last_half_century, TDuration::Days(18262));