From cdaa1e0196b1025b526bea061cf6217ff280bb99 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Wed, 20 Jul 2022 11:21:13 +0200 Subject: [PATCH] Feat: Benchmarks --- Implementierung/.gitignore | 2 +- Implementierung/Makefile | 38 +++++++++++++++++++++++++++++++--- Implementierung/benchmarks.csv | 1 + 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 Implementierung/benchmarks.csv diff --git a/Implementierung/.gitignore b/Implementierung/.gitignore index d6dce6b..37e27d3 100644 --- a/Implementierung/.gitignore +++ b/Implementierung/.gitignore @@ -1,3 +1,3 @@ build md2 -testfile* \ No newline at end of file +t \ No newline at end of file diff --git a/Implementierung/Makefile b/Implementierung/Makefile index 843d95b..7be2eba 100644 --- a/Implementierung/Makefile +++ b/Implementierung/Makefile @@ -5,6 +5,8 @@ OBJ = ${subst src,build,${SRC:.c=.o}} CC = gcc CFLAGS = -Ilib -ggdb -std=c11 -g -Wall -Wextra -no-pie -O3 LDFLAGS = +TESTFILES = t/1 t/10 t/100 #t/1000 t/2000 t/5000 t/10000 +TESTFILES_SIZES = ${subst t/,,${TESTFILES}} all: md2 @@ -18,9 +20,7 @@ help: @echo - all: build everything @echo - clean: clean distfiles @echo - help: show this help - -build: - mkdir build + @echo - benchmarks: run benchmarks (only works on linux!) build/%.o: src/%.c @mkdir -p build/md2_impls @@ -29,4 +29,36 @@ build/%.o: src/%.c md2: ${OBJ} ${CC} -o $@ $(OBJ) ${LDFLAGS} +t/%: + @echo + @echo "=== Generating ${subst t/,,$@}MB of random data... ===" + dd if=/dev/random of=$@ bs=1M count=${subst t/,,$@} status=progress + @echo "=== done ===" + @echo + +benchmarks.csv: ${TESTFILES} + @echo "" > $@ + @for i in 0 1 2 3; do \ + echo ;\ + echo "=== Testing implementation $$i ===";\ + for t in $(TESTFILES_SIZES); do \ + echo -n "- with $${t}MB ... "; \ + if ! r=$$(./md2 t/$${t} -B1 -V1); then \ + echo; \ + echo "ERROR!"; \ + exit 1; \ + fi; \ + r=$$(echo $$r | grep "cycles took" | sed 's/ seconds//g' | sed 's/took /\n/g' | tail -1) \ + echo $$?; \ + echo "$${r}s"; \ + echo "$${i};$${t};$${r}" >> $@; \ + done; \ + echo "=== done ===";\ + echo;\ + done + + +tests: md2 + + .PHONY: all clean help \ No newline at end of file diff --git a/Implementierung/benchmarks.csv b/Implementierung/benchmarks.csv new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Implementierung/benchmarks.csv @@ -0,0 +1 @@ +