Loading liblog/logger_write.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading @@ -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; Loading liblog/tests/liblog_benchmark.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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); Loading
liblog/logger_write.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading @@ -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; Loading
liblog/tests/liblog_benchmark.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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);