am 370704d6: Merge "Add benchmarks for pthread_rw_locks"

* commit '370704d69db15ec0b4d24e6412b5d30ded0ffc03':
  Add benchmarks for pthread_rw_locks
This commit is contained in:
Calin Juravle 2014-09-16 19:52:58 +00:00 committed by Android Git Automerger
commit c417053e80

View File

@ -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);