summaryrefslogtreecommitdiffstats
path: root/benchmarks
diff options
context:
space:
mode:
authorCalin Juravle <calin@google.com>2014-09-16 18:01:44 +0100
committerCalin Juravle <calin@google.com>2014-09-16 18:02:30 +0100
commit837a962bf5473eeec1668de1104800ff4a53bdd1 (patch)
tree534b8dab5e5def8025c976977b130932b5883338 /benchmarks
parent2997ae83d55486ab86a6100265fa502eff721ce2 (diff)
downloadbionic-837a962bf5473eeec1668de1104800ff4a53bdd1.zip
bionic-837a962bf5473eeec1668de1104800ff4a53bdd1.tar.gz
bionic-837a962bf5473eeec1668de1104800ff4a53bdd1.tar.bz2
Add benchmarks for pthread_rw_locks
Benchmarks for the following sequences: 1) pthread_rwlock_rdlock -> pthread_rwlock_unlock 2) pthread_rwlock_wrlock -> pthread_rwlock_unlock Change-Id: I8d87d4d8afab8637ea7ff5d23a0b3a81d6d40835
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/pthread_benchmark.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/benchmarks/pthread_benchmark.cpp b/benchmarks/pthread_benchmark.cpp
index c010dd2..11db56d 100644
--- a/benchmarks/pthread_benchmark.cpp
+++ b/benchmarks/pthread_benchmark.cpp
@@ -105,3 +105,35 @@ static void BM_pthread_mutex_lock_RECURSIVE(int iters) {
StopBenchmarkTiming();
}
BENCHMARK(BM_pthread_mutex_lock_RECURSIVE);
+
+static void BM_pthread_rw_lock_read(int iters) {
+ StopBenchmarkTiming();
+ pthread_rwlock_t lock;
+ pthread_rwlock_init(&lock, NULL);
+ StartBenchmarkTiming();
+
+ for (int i = 0; i < iters; ++i) {
+ pthread_rwlock_rdlock(&lock);
+ pthread_rwlock_unlock(&lock);
+ }
+
+ StopBenchmarkTiming();
+ pthread_rwlock_destroy(&lock);
+}
+BENCHMARK(BM_pthread_rw_lock_read);
+
+static void BM_pthread_rw_lock_write(int iters) {
+ StopBenchmarkTiming();
+ pthread_rwlock_t lock;
+ pthread_rwlock_init(&lock, NULL);
+ StartBenchmarkTiming();
+
+ for (int i = 0; i < iters; ++i) {
+ pthread_rwlock_wrlock(&lock);
+ pthread_rwlock_unlock(&lock);
+ }
+
+ StopBenchmarkTiming();
+ pthread_rwlock_destroy(&lock);
+}
+BENCHMARK(BM_pthread_rw_lock_write);