summaryrefslogtreecommitdiffstats
path: root/liblog
diff options
context:
space:
mode:
authorMark Salyzyn2017-09-11 15:29:59 -0500
committerMark Salyzyn2018-01-16 10:11:59 -0600
commitdc3c14720fb5702da67258067d89ddc51245c5d0 (patch)
tree3a474205353b24c72936226ca95192826a2763c2 /liblog
parent1520bd43b0ce6511cd086eaf495692c4bc2f6d6b (diff)
downloadplatform-system-core-dc3c14720fb5702da67258067d89ddc51245c5d0.tar.gz
platform-system-core-dc3c14720fb5702da67258067d89ddc51245c5d0.tar.xz
platform-system-core-dc3c14720fb5702da67258067d89ddc51245c5d0.zip
liblog: clock_gettime, clock_getres and time benchmarks
Add local BM_time_clock_gettime_*, BM_time_clock_getres_* and BM_time_time benchmarks. Relates to the bionic benchmarks of the same names, except adds CLOCK_MONOTONIC_RAW. Added here for developer convenience whenever updates to the liblog or logd code base need integration testing. ToDo: add liblog gTests that analyse the benchmark data to confirm that the specified integrated device has vdso access to all the pertinent clock sources. Add liblog local benchmarks and tests to measure the device clock drift of each possible liblog clock source to help evaluate device configuration. Test: liblog_benchmarks --benchmark_filter=BM_time* Bug: 63737556 Bug: 69423514 Change-Id: Ibafe0880d976ef2b3885765f71e0ba6c99d56f2a
Diffstat (limited to 'liblog')
-rw-r--r--liblog/tests/liblog_benchmark.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/liblog/tests/liblog_benchmark.cpp b/liblog/tests/liblog_benchmark.cpp
index 706a0f6ae..c2f3f837a 100644
--- a/liblog/tests/liblog_benchmark.cpp
+++ b/liblog/tests/liblog_benchmark.cpp
@@ -19,6 +19,7 @@
19#include <poll.h> 19#include <poll.h>
20#include <sys/endian.h> 20#include <sys/endian.h>
21#include <sys/socket.h> 21#include <sys/socket.h>
22#include <sys/syscall.h>
22#include <sys/types.h> 23#include <sys/types.h>
23#include <unistd.h> 24#include <unistd.h>
24 25
@@ -107,6 +108,65 @@ static void BM_clock_overhead(benchmark::State& state) {
107} 108}
108BENCHMARK(BM_clock_overhead); 109BENCHMARK(BM_clock_overhead);
109 110
111static void do_clock_overhead(benchmark::State& state, clockid_t clk_id) {
112 timespec t;
113 while (state.KeepRunning()) {
114 clock_gettime(clk_id, &t);
115 }
116}
117
118static void BM_time_clock_gettime_REALTIME(benchmark::State& state) {
119 do_clock_overhead(state, CLOCK_REALTIME);
120}
121BENCHMARK(BM_time_clock_gettime_REALTIME);
122
123static void BM_time_clock_gettime_MONOTONIC(benchmark::State& state) {
124 do_clock_overhead(state, CLOCK_MONOTONIC);
125}
126BENCHMARK(BM_time_clock_gettime_MONOTONIC);
127
128static void BM_time_clock_gettime_MONOTONIC_syscall(benchmark::State& state) {
129 timespec t;
130 while (state.KeepRunning()) {
131 syscall(__NR_clock_gettime, CLOCK_MONOTONIC, &t);
132 }
133}
134BENCHMARK(BM_time_clock_gettime_MONOTONIC_syscall);
135
136static void BM_time_clock_gettime_MONOTONIC_RAW(benchmark::State& state) {
137 do_clock_overhead(state, CLOCK_MONOTONIC_RAW);
138}
139BENCHMARK(BM_time_clock_gettime_MONOTONIC_RAW);
140
141static void BM_time_clock_gettime_BOOTTIME(benchmark::State& state) {
142 do_clock_overhead(state, CLOCK_BOOTTIME);
143}
144BENCHMARK(BM_time_clock_gettime_BOOTTIME);
145
146static void BM_time_clock_getres_MONOTONIC(benchmark::State& state) {
147 timespec t;
148 while (state.KeepRunning()) {
149 clock_getres(CLOCK_MONOTONIC, &t);
150 }
151}
152BENCHMARK(BM_time_clock_getres_MONOTONIC);
153
154static void BM_time_clock_getres_MONOTONIC_syscall(benchmark::State& state) {
155 timespec t;
156 while (state.KeepRunning()) {
157 syscall(__NR_clock_getres, CLOCK_MONOTONIC, &t);
158 }
159}
160BENCHMARK(BM_time_clock_getres_MONOTONIC_syscall);
161
162static void BM_time_time(benchmark::State& state) {
163 while (state.KeepRunning()) {
164 time_t now;
165 now = time(&now);
166 }
167}
168BENCHMARK(BM_time_time);
169
110/* 170/*
111 * Measure the time it takes to submit the android logging data to pstore 171 * Measure the time it takes to submit the android logging data to pstore
112 */ 172 */