mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
add a benchmark for standard std::chrono clocks
Summary: Querying clocks has a cost. Add a microbenchmark for measuring that cost on all platforms. Reviewed By: genevievehelsel Differential Revision: D42182073 fbshipit-source-id: facb907fc4abed74625e0e28fe3ab63d8335a9fd
This commit is contained in:
parent
d934cb3715
commit
f0e16a3f02
37
eden/fs/benchmarks/language/clock.cpp
Normal file
37
eden/fs/benchmarks/language/clock.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This software may be used and distributed according to the terms of the
|
||||
* GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#include <chrono>
|
||||
#include "eden/common/utils/benchharness/Bench.h"
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace benchmark;
|
||||
using namespace facebook::eden;
|
||||
|
||||
void system_clock(benchmark::State& state) {
|
||||
for (auto _ : state) {
|
||||
benchmark::DoNotOptimize(std::chrono::system_clock::now());
|
||||
}
|
||||
}
|
||||
BENCHMARK(system_clock);
|
||||
|
||||
void steady_clock(benchmark::State& state) {
|
||||
for (auto _ : state) {
|
||||
benchmark::DoNotOptimize(std::chrono::steady_clock::now());
|
||||
}
|
||||
}
|
||||
BENCHMARK(steady_clock);
|
||||
|
||||
void high_resolution_clock(benchmark::State& state) {
|
||||
for (auto _ : state) {
|
||||
benchmark::DoNotOptimize(std::chrono::high_resolution_clock::now());
|
||||
}
|
||||
}
|
||||
BENCHMARK(high_resolution_clock);
|
||||
|
||||
} // namespace
|
Loading…
Reference in New Issue
Block a user