22 #include "benchmark/benchmark.h" 26 void BM_Clock_Now_AbslTime(benchmark::State& state) {
27 while (state.KeepRunning()) {
31 BENCHMARK(BM_Clock_Now_AbslTime);
33 void BM_Clock_Now_GetCurrentTimeNanos(benchmark::State& state) {
34 while (state.KeepRunning()) {
38 BENCHMARK(BM_Clock_Now_GetCurrentTimeNanos);
40 void BM_Clock_Now_AbslTime_ToUnixNanos(benchmark::State& state) {
41 while (state.KeepRunning()) {
45 BENCHMARK(BM_Clock_Now_AbslTime_ToUnixNanos);
47 void BM_Clock_Now_CycleClock(benchmark::State& state) {
48 while (state.KeepRunning()) {
52 BENCHMARK(BM_Clock_Now_CycleClock);
55 static void BM_Clock_Now_gettimeofday(benchmark::State& state) {
57 while (state.KeepRunning()) {
58 benchmark::DoNotOptimize(gettimeofday(&tv,
nullptr));
61 BENCHMARK(BM_Clock_Now_gettimeofday);
63 static void BM_Clock_Now_clock_gettime(benchmark::State& state) {
65 while (state.KeepRunning()) {
66 benchmark::DoNotOptimize(clock_gettime(CLOCK_REALTIME, &ts));
69 BENCHMARK(BM_Clock_Now_clock_gettime);
int64_t GetCurrentTimeNanos()
int64_t ToUnixNanos(Time t)