summaryrefslogtreecommitdiffstats
path: root/benchmarks
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2014-12-03 21:36:24 -0800
committerYabin Cui <yabinc@google.com>2014-12-19 16:05:29 -0800
commit8cf1b305670123aed7638d984ca39bfd22388440 (patch)
treef8fc12a882822ca1ba41b68d84414e252faade9c /benchmarks
parentc631bb215e29981222f19c092ded49c7c1f15845 (diff)
downloadbionic-8cf1b305670123aed7638d984ca39bfd22388440.zip
bionic-8cf1b305670123aed7638d984ca39bfd22388440.tar.gz
bionic-8cf1b305670123aed7638d984ca39bfd22388440.tar.bz2
Use mmap to create the pthread_internal_t
Add name to mmaped regions. Add pthread benchmark code. Allocate pthread_internal_t on regular stack. Bug: 16847284 Change-Id: Id60835163bb0d68092241f1a118015b5a8f85069
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/pthread_benchmark.cpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/benchmarks/pthread_benchmark.cpp b/benchmarks/pthread_benchmark.cpp
index 92e5998..42023e0 100644
--- a/benchmarks/pthread_benchmark.cpp
+++ b/benchmarks/pthread_benchmark.cpp
@@ -47,6 +47,21 @@ static void BM_pthread_getspecific(int iters) {
}
BENCHMARK(BM_pthread_getspecific);
+static void BM_pthread_setspecific(int iters) {
+ StopBenchmarkTiming();
+ pthread_key_t key;
+ pthread_key_create(&key, NULL);
+ StartBenchmarkTiming();
+
+ for (int i = 0; i < iters; ++i) {
+ pthread_setspecific(key, NULL);
+ }
+
+ StopBenchmarkTiming();
+ pthread_key_delete(key);
+}
+BENCHMARK(BM_pthread_setspecific);
+
static void DummyPthreadOnceInitFunction() {
}
@@ -137,3 +152,80 @@ static void BM_pthread_rw_lock_write(int iters) {
pthread_rwlock_destroy(&lock);
}
BENCHMARK(BM_pthread_rw_lock_write);
+
+static void* IdleThread(void*) {
+ return NULL;
+}
+
+static void BM_pthread_create(int iters) {
+ StopBenchmarkTiming();
+ pthread_t thread;
+
+ for (int i = 0; i < iters; ++i) {
+ StartBenchmarkTiming();
+ pthread_create(&thread, NULL, IdleThread, NULL);
+ StopBenchmarkTiming();
+ pthread_join(thread, NULL);
+ }
+}
+BENCHMARK(BM_pthread_create);
+
+static void* RunThread(void*) {
+ StopBenchmarkTiming();
+ return NULL;
+}
+
+static void BM_pthread_create_and_run(int iters) {
+ StopBenchmarkTiming();
+ pthread_t thread;
+
+ for (int i = 0; i < iters; ++i) {
+ StartBenchmarkTiming();
+ pthread_create(&thread, NULL, RunThread, NULL);
+ pthread_join(thread, NULL);
+ }
+}
+BENCHMARK(BM_pthread_create_and_run);
+
+static void* ExitThread(void*) {
+ StartBenchmarkTiming();
+ pthread_exit(NULL);
+}
+
+static void BM_pthread_exit_and_join(int iters) {
+ StopBenchmarkTiming();
+ pthread_t thread;
+
+ for (int i = 0; i < iters; ++i) {
+ pthread_create(&thread, NULL, ExitThread, NULL);
+ pthread_join(thread, NULL);
+ StopBenchmarkTiming();
+ }
+}
+BENCHMARK(BM_pthread_exit_and_join);
+
+static void BM_pthread_key_create(int iters) {
+ StopBenchmarkTiming();
+ pthread_key_t key;
+
+ for (int i = 0; i < iters; ++i) {
+ StartBenchmarkTiming();
+ pthread_key_create(&key, NULL);
+ StopBenchmarkTiming();
+ pthread_key_delete(key);
+ }
+}
+BENCHMARK(BM_pthread_key_create);
+
+static void BM_pthread_key_delete(int iters) {
+ StopBenchmarkTiming();
+ pthread_key_t key;
+
+ for (int i = 0; i < iters; ++i) {
+ pthread_key_create(&key, NULL);
+ StartBenchmarkTiming();
+ pthread_key_delete(key);
+ StopBenchmarkTiming();
+ }
+}
+BENCHMARK(BM_pthread_key_delete);