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

Commit df35dfbc authored by Tom Cherry's avatar Tom Cherry Committed by Gerrit Code Review
Browse files

Merge changes I09a60e61,I2b898e72

* changes:
  liblog: add benchmark tests for not-printed message
  liblog: add __attribute__((uninitialized)) to liblog buffers
parents d9de138e 662b4691
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -348,7 +348,7 @@ int __android_log_vprint(int prio, const char* tag, const char* fmt, va_list ap)
    return 0;
  }

  char buf[LOG_BUF_SIZE];
  __attribute__((uninitialized)) char buf[LOG_BUF_SIZE];

  vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);

@@ -366,7 +366,7 @@ int __android_log_print(int prio, const char* tag, const char* fmt, ...) {
  }

  va_list ap;
  char buf[LOG_BUF_SIZE];
  __attribute__((uninitialized)) char buf[LOG_BUF_SIZE];

  va_start(ap, fmt);
  vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
@@ -386,7 +386,7 @@ int __android_log_buf_print(int bufID, int prio, const char* tag, const char* fm
  }

  va_list ap;
  char buf[LOG_BUF_SIZE];
  __attribute__((uninitialized)) char buf[LOG_BUF_SIZE];

  va_start(ap, fmt);
  vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
@@ -398,7 +398,7 @@ int __android_log_buf_print(int bufID, int prio, const char* tag, const char* fm
}

void __android_log_assert(const char* cond, const char* tag, const char* fmt, ...) {
  char buf[LOG_BUF_SIZE];
  __attribute__((uninitialized)) char buf[LOG_BUF_SIZE];

  if (fmt) {
    va_list ap;
+12 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include <unordered_set>

#include <android-base/file.h>
#include <android-base/properties.h>
#include <benchmark/benchmark.h>
#include <cutils/sockets.h>
#include <log/event_tag_map.h>
@@ -1025,3 +1026,14 @@ static void BM_lookupEventTagNum_logd_existing(benchmark::State& state) {
  }
}
BENCHMARK(BM_lookupEventTagNum_logd_existing);

static void BM_log_verbose_overhead(benchmark::State& state) {
  std::string test_log_tag = "liblog_verbose_tag";
  android::base::SetProperty("log.tag." + test_log_tag, "I");
  for (auto _ : state) {
    __android_log_print(ANDROID_LOG_VERBOSE, test_log_tag.c_str(), "%s test log message %d %d",
                        "test test", 123, 456);
  }
  android::base::SetProperty("log.tag." + test_log_tag, "");
}
BENCHMARK(BM_log_verbose_overhead);