aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes2014-05-30 21:00:03 -0500
committerElliott Hughes2014-06-02 12:32:55 -0500
commit5d9a7ba0dc9c24ed4e4efa9cac0e796fd524b308 (patch)
tree4674df3b5064cb38211453b6e887c364f0c66f05 /benchmarks
parent831405b749d15a11fb947a40d61fd858e952d860 (diff)
downloadplatform-bionic-5d9a7ba0dc9c24ed4e4efa9cac0e796fd524b308.tar.gz
platform-bionic-5d9a7ba0dc9c24ed4e4efa9cac0e796fd524b308.tar.xz
platform-bionic-5d9a7ba0dc9c24ed4e4efa9cac0e796fd524b308.zip
Avoid a system call in 'gettid'.
System calls can be pretty slow. This is mako, which has one of our lowest latencies: iterations ns/op BM_unistd_getpid 10000000 209 BM_unistd_gettid 200000000 8 Bug: 15297299 (kernel panic from too many gettid calls) Bug: 15315766 (excessive gettid overhead in liblogd) Change-Id: I49656c0fc5b5d092390264a59e4f2c0d8a8b1aeb
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/unistd_benchmark.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/benchmarks/unistd_benchmark.cpp b/benchmarks/unistd_benchmark.cpp
index e839bf8b..12b788ac 100644
--- a/benchmarks/unistd_benchmark.cpp
+++ b/benchmarks/unistd_benchmark.cpp
@@ -28,3 +28,14 @@ static void BM_unistd_getpid(int iters) {
28 StopBenchmarkTiming(); 28 StopBenchmarkTiming();
29} 29}
30BENCHMARK(BM_unistd_getpid); 30BENCHMARK(BM_unistd_getpid);
31
32static void BM_unistd_gettid(int iters) {
33 StartBenchmarkTiming();
34
35 for (int i = 0; i < iters; ++i) {
36 gettid();
37 }
38
39 StopBenchmarkTiming();
40}
41BENCHMARK(BM_unistd_gettid);