Commit df1a38dd authored by Tomas Krizek's avatar Tomas Krizek

meson: bench - compile and run

parent 4847edef
bench_BIN := \
bench_lru
# Dependencies
bench_DEPEND := $(libkres)
bench_LIBS := $(libkres_TARGET) $(libkres_LIBS)
# Make bench binaries
define make_bench
$(1)_CFLAGS := -fPIE
$(1)_SOURCES := bench/$(1).c
$(1)_LIBS := $(bench_LIBS)
$(1)_DEPEND := $(bench_DEPEND)
$(call make_bin,$(1),bench)
endef
$(foreach bench,$(bench_BIN),$(eval $(call make_bench,$(bench))))
# Targets
.PHONY: bench bench-clean
bench-clean: $(foreach bench,$(bench_BIN),$(bench)-clean)
bench: $(foreach bench,$(bench_BIN),bench/$(bench))
@echo "Test LRU with increasing overfill, misses should increase ~ linearly" >&2
$(preload_syms) ./bench/bench_lru 23 bench/bench_lru_set1.tsv - 65536 # fill ~ 1
$(preload_syms) ./bench/bench_lru 23 bench/bench_lru_set1.tsv - 32768 # fill ~ 2
$(preload_syms) ./bench/bench_lru 23 bench/bench_lru_set1.tsv - 16384 # fill ~ 4
$(preload_syms) ./bench/bench_lru 23 bench/bench_lru_set1.tsv - 8192 # fill ~ 8
$(preload_syms) ./bench/bench_lru 23 bench/bench_lru_set1.tsv - 4096 # fill ~ 16
......@@ -33,6 +33,10 @@ typedef kr_nsrep_lru_t lru_bench_t;
} while (0)
#define p_err(...) fprintf(stderr, __VA_ARGS__)
#ifndef LRU_RTT_SIZE
#define LRU_RTT_SIZE 65536 /**< NS RTT cache size */
#endif
static int die(const char *cause)
{
fprintf(stderr, "%s: %s\n", cause, strerror(errno));
......
# bench
bench_lru_src = [
'bench_lru.c',
]
cc = meson.get_compiler('c')
m_dep = cc.find_library('m', required : false)
bench_lru = executable(
'bench_lru',
bench_lru_src,
dependencies: [
contrib_dep,
libkres_dep,
m_dep,
],
)
run_target(
'bench',
command: '../scripts/bench.sh',
)
......@@ -163,6 +163,9 @@ subdir('lib')
subdir('client')
subdir('daemon')
subdir('modules')
if get_option('bench').enabled()
subdir('bench')
endif
# Tests
......
......@@ -63,6 +63,13 @@ option(
# Component options
option(
'bench',
type: 'feature',
value: 'disabled',
description: 'build benchmarks'
)
option(
'client',
type: 'feature',
......
#!/bin/bash
set -o errexit -o nounset
# Run benchmark
cd "${MESON_SOURCE_ROOT}"
echo "Test LRU with increasing overfill, misses should increase ~ linearly"
for num in 65536 32768 16384 8192 4096; do
"${MESON_BUILD_ROOT}/${MESON_SUBDIR}/bench_lru" 23 "${MESON_SOURCE_ROOT}/${MESON_SUBDIR}/bench_lru_set1.tsv" - "${num}"
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment