Skip to content

Commit 171a1eb

Browse files
committed
fixup: add ns bench
1 parent 4620e06 commit 171a1eb

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

examples/google_benchmark_cmake/sleep_bench.hpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,34 @@ static inline void busy_sleep_for(std::chrono::nanoseconds duration) {
1212
}
1313
}
1414

15+
static void BM_sleep_1ns(benchmark::State& state) {
16+
for (auto _ : state) {
17+
busy_sleep_for(std::chrono::nanoseconds(1));
18+
}
19+
}
20+
BENCHMARK(BM_sleep_1ns);
21+
22+
static void BM_sleep_10ns(benchmark::State& state) {
23+
for (auto _ : state) {
24+
busy_sleep_for(std::chrono::nanoseconds(10));
25+
}
26+
}
27+
BENCHMARK(BM_sleep_10ns);
28+
29+
static void BM_sleep_50ns(benchmark::State& state) {
30+
for (auto _ : state) {
31+
busy_sleep_for(std::chrono::nanoseconds(50));
32+
}
33+
}
34+
BENCHMARK(BM_sleep_50ns);
35+
36+
static void BM_sleep_100ns(benchmark::State& state) {
37+
for (auto _ : state) {
38+
busy_sleep_for(std::chrono::nanoseconds(100));
39+
}
40+
}
41+
BENCHMARK(BM_sleep_100ns);
42+
1543
static void BM_sleep_1us(benchmark::State& state) {
1644
for (auto _ : state) {
1745
busy_sleep_for(std::chrono::microseconds(1));

0 commit comments

Comments
 (0)