summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/benchs/run_bench_libarena.sh
blob: 10afe4d52ebf7002ddbc33847a095a4641c27532 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

source ./benchs/run_common.sh

set -eufo pipefail

RUN_BENCH="./bench -d3 -q"

summarize_libarena()
{
	local bench="$1"
	local summary

	summary=$(printf '%s\n' "$2" | tail -n1)
	summary=${summary#Summary: }
	printf "%-20s %s\n" "$bench" "$summary"
}

header "libarena sequential malloc\n"

for size in 16 64 256 1024 4096; do
subtitle "allocation size: $size"
printf "\t-------------------\n"
	for nallocs in 10 50 100 500 1000 5000 10000; do
		summarize_libarena "malloc:" \
			"$($RUN_BENCH --alloc_size "$size" --nallocs "$nallocs" libarena-malloc)"
		summarize_libarena "calloc:" \
			"$($RUN_BENCH --alloc_size "$size" --nallocs "$nallocs" libarena-calloc)"
	done
done