From 7634db5a0657129225869c3650a992f9cbe82fe4 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 9 Jun 2014 18:35:21 -0700 Subject: [PATCH] Add a couple more system call benchmarks. Bug: 15387103 Change-Id: I13419ddf77d201fdbde4c784259c0cb0dcfb9a77 --- benchmarks/time_benchmark.cpp | 13 +++++++++++++ benchmarks/unistd_benchmark.cpp | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/benchmarks/time_benchmark.cpp b/benchmarks/time_benchmark.cpp index 75132e50e..3bf8c07f6 100644 --- a/benchmarks/time_benchmark.cpp +++ b/benchmarks/time_benchmark.cpp @@ -35,4 +35,17 @@ static void BM_time_localtime_tz(int iters) { StopBenchmarkTiming(); } BENCHMARK(BM_time_localtime_tz); + #endif + +static void BM_time_clock_gettime(int iters) { + StartBenchmarkTiming(); + + struct timespec t; + for (int i = 0; i < iters; ++i) { + clock_gettime(CLOCK_MONOTONIC, &t); + } + + StopBenchmarkTiming(); +} +BENCHMARK(BM_time_clock_gettime); diff --git a/benchmarks/unistd_benchmark.cpp b/benchmarks/unistd_benchmark.cpp index 12b788acd..f2c9d73cf 100644 --- a/benchmarks/unistd_benchmark.cpp +++ b/benchmarks/unistd_benchmark.cpp @@ -16,6 +16,7 @@ #include "benchmark.h" +#include #include static void BM_unistd_getpid(int iters) { @@ -39,3 +40,14 @@ static void BM_unistd_gettid(int iters) { StopBenchmarkTiming(); } BENCHMARK(BM_unistd_gettid); + +static void BM_unistd_gettid_syscall(int iters) { + StartBenchmarkTiming(); + + for (int i = 0; i < iters; ++i) { + syscall(__NR_gettid); + } + + StopBenchmarkTiming(); +} +BENCHMARK(BM_unistd_gettid_syscall);