summaryrefslogtreecommitdiff
path: root/benchmarks/malloc_benchmark.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2019-04-05 12:47:39 -0700
committerChristopher Ferris <cferris@google.com>2019-04-05 14:45:15 -0700
commit7ec2c8a9b6f9a050d2ac9e0c35f0a631573f3de6 (patch)
tree289ddc73370f240d2feabf59fa855d11e04df3ce /benchmarks/malloc_benchmark.cpp
parent1701d887aca0374c000a018a974227064e77d769 (diff)
Add malloc benchmarks.
Adding some benchmarks that keep a certain number of allocation around. This benchmark should not be used as an absolute for determining what is a good/bad native allocator. However, it should be used to make sure that numbers are not completely changed between allocator versions. Also update the malloc sql benchmark to match the same style as these new benchmarks. Bug: 129743239 Test: Ran these benchmarks. Change-Id: I1995d98fd269b61d9c96efed6eff3ed278e24c97
Diffstat (limited to 'benchmarks/malloc_benchmark.cpp')
-rw-r--r--benchmarks/malloc_benchmark.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/benchmarks/malloc_benchmark.cpp b/benchmarks/malloc_benchmark.cpp
index 2fa1c87fd..ca54f11e3 100644
--- a/benchmarks/malloc_benchmark.cpp
+++ b/benchmarks/malloc_benchmark.cpp
@@ -102,22 +102,27 @@ void BenchmarkMalloc(MallocEntry entries[], size_t total_entries, size_t max_all
// bionic/libc/malloc_debug/tools/gen_malloc.pl -i <THREAD_ID> g_sql_entries kMaxSqlAllocSlots < <ALLOC_FILE> > malloc_sql.h
#include "malloc_sql.h"
-static void BM_malloc_sql_trace_decay_time_0(benchmark::State& state) {
+static void BM_malloc_sql_trace_default(benchmark::State& state) {
+ // The default is expected to be a zero decay time.
mallopt(M_DECAY_TIME, 0);
+
for (auto _ : state) {
BenchmarkMalloc(g_sql_entries, sizeof(g_sql_entries) / sizeof(MallocEntry),
kMaxSqlAllocSlots);
}
}
-BIONIC_BENCHMARK(BM_malloc_sql_trace_decay_time_0);
+BIONIC_BENCHMARK(BM_malloc_sql_trace_default);
-static void BM_malloc_sql_trace_decay_time_1(benchmark::State& state) {
+static void BM_malloc_sql_trace_decay1(benchmark::State& state) {
mallopt(M_DECAY_TIME, 1);
+
for (auto _ : state) {
BenchmarkMalloc(g_sql_entries, sizeof(g_sql_entries) / sizeof(MallocEntry),
kMaxSqlAllocSlots);
}
+
+ mallopt(M_DECAY_TIME, 0);
}
-BIONIC_BENCHMARK(BM_malloc_sql_trace_decay_time_1);
+BIONIC_BENCHMARK(BM_malloc_sql_trace_decay1);
#endif