Commit 556fcb57 by Dmitry Vyukov Committed by Copybara-Service

absl: add Mutex::ReaderLock benchmark

PiperOrigin-RevId: 566961701
Change-Id: Id04e4c5a598f508a0fe7532ae8f084c583865f2d
parent d91f39ab
...@@ -34,6 +34,14 @@ void BM_Mutex(benchmark::State& state) { ...@@ -34,6 +34,14 @@ void BM_Mutex(benchmark::State& state) {
} }
BENCHMARK(BM_Mutex)->UseRealTime()->Threads(1)->ThreadPerCpu(); BENCHMARK(BM_Mutex)->UseRealTime()->Threads(1)->ThreadPerCpu();
void BM_ReaderLock(benchmark::State& state) {
static absl::Mutex* mu = new absl::Mutex;
for (auto _ : state) {
absl::ReaderMutexLock lock(mu);
}
}
BENCHMARK(BM_ReaderLock)->UseRealTime()->Threads(1)->ThreadPerCpu();
static void DelayNs(int64_t ns, int* data) { static void DelayNs(int64_t ns, int* data) {
int64_t end = absl::base_internal::CycleClock::Now() + int64_t end = absl::base_internal::CycleClock::Now() +
ns * absl::base_internal::CycleClock::Frequency() / 1e9; ns * absl::base_internal::CycleClock::Frequency() / 1e9;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment