Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe8c96d1 authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

liblog: benchmark add BM_log_event_overhead_42 for a well known tag

Measure the cost of using a known test event log tag from
system/core/logcat/event.logtags:

42    answer (to life the universe etc|3)

Test: liblog_benchmarks BM_log_event_overhead_42
Bug: 36683634
Change-Id: Ibd4be82bebfcedd381c84e8078cf6d05a636aa98
parent cf29755e
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
@@ -527,11 +527,13 @@ BENCHMARK(BM_log_print_overhead);
/*
 *	Measure the time it takes to submit the android event logging call
 * using discrete acquisition (StartBenchmarkTiming() -> StopBenchmarkTiming())
 * under light load. Expect this to be a dozen or so syscall periods (40us)
 * under light load. Expect this to be a long path to logger to convert the
 * unknown tag (0) into a tagname (less than 200us).
 */
static void BM_log_event_overhead(int iters) {
  for (unsigned long long i = 0; i < (unsigned)iters; ++i) {
    StartBenchmarkTiming();
    // log tag number 0 is not known, nor shall it ever be known
    __android_log_btwrite(0, EVENT_TYPE_LONG, &i, sizeof(i));
    StopBenchmarkTiming();
    logd_yield();
@@ -539,6 +541,28 @@ static void BM_log_event_overhead(int iters) {
}
BENCHMARK(BM_log_event_overhead);

/*
 *	Measure the time it takes to submit the android event logging call
 * using discrete acquisition (StartBenchmarkTiming() -> StopBenchmarkTiming())
 * under light load with a known logtag.  Expect this to be a dozen or so
 * syscall periods (less than 40us)
 */
static void BM_log_event_overhead_42(int iters) {
  for (unsigned long long i = 0; i < (unsigned)iters; ++i) {
    StartBenchmarkTiming();
    // In system/core/logcat/event.logtags:
    // # These are used for testing, do not modify without updating
    // # tests/framework-tests/src/android/util/EventLogFunctionalTest.java.
    // # system/core/liblog/tests/liblog_benchmark.cpp
    // # system/core/liblog/tests/liblog_test.cpp
    // 42    answer (to life the universe etc|3)
    __android_log_btwrite(42, EVENT_TYPE_LONG, &i, sizeof(i));
    StopBenchmarkTiming();
    logd_yield();
  }
}
BENCHMARK(BM_log_event_overhead_42);

static void BM_log_event_overhead_null(int iters) {
  set_log_null();
  BM_log_event_overhead(iters);
+2 −0
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@

# These are used for testing, do not modify without updating
# tests/framework-tests/src/android/util/EventLogFunctionalTest.java.
# system/core/liblog/tests/liblog_benchmark.cpp
# system/core/liblog/tests/liblog_test.cpp
42    answer (to life the universe etc|3)
314   pi
2718  e