diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2023-09-20 07:46:16 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-09-20 07:47:01 -0700 |
commit | 556fcb57eb5f87e137c7db39b5a60ab3c4aa525f (patch) | |
tree | 15c75e9dd35c845ac0b1ebaeeb9302ee185806e0 /absl/synchronization | |
parent | d91f39ab5b910ee208bf8d7dec6a65cfa0b879ba (diff) |
absl: add Mutex::ReaderLock benchmark
PiperOrigin-RevId: 566961701
Change-Id: Id04e4c5a598f508a0fe7532ae8f084c583865f2d
Diffstat (limited to 'absl/synchronization')
-rw-r--r-- | absl/synchronization/mutex_benchmark.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/absl/synchronization/mutex_benchmark.cc b/absl/synchronization/mutex_benchmark.cc index b5d2fbc4..0af56d9e 100644 --- a/absl/synchronization/mutex_benchmark.cc +++ b/absl/synchronization/mutex_benchmark.cc @@ -34,6 +34,14 @@ void BM_Mutex(benchmark::State& state) { } 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) { int64_t end = absl::base_internal::CycleClock::Now() + ns * absl::base_internal::CycleClock::Frequency() / 1e9; |