2022-06-29 11:40:12 +02:00
|
|
|
|
|
|
|
|
2022-07-15 00:01:35 +02:00
|
|
|
SRC = src/main.c src/helper.c src/io.c src/md2.c src/md2_impls/md2_common.c src/md2_impls/md2_0.c src/md2_impls/md2_2.c src/md2_impls/md2_3.c
|
2022-06-29 14:47:58 +02:00
|
|
|
OBJ = ${subst src,build,${SRC:.c=.o}}
|
|
|
|
CC = gcc
|
2022-07-19 22:27:56 +02:00
|
|
|
CFLAGS = -Ilib -ggdb -std=c11 -g -Wall -Wextra -no-pie -O3
|
|
|
|
LDFLAGS = -pthread
|
2022-07-20 11:21:13 +02:00
|
|
|
TESTFILES = t/1 t/10 t/100 #t/1000 t/2000 t/5000 t/10000
|
|
|
|
TESTFILES_SIZES = ${subst t/,,${TESTFILES}}
|
2022-06-29 11:40:12 +02:00
|
|
|
|
2022-06-29 14:47:58 +02:00
|
|
|
all: md2
|
2022-06-29 11:40:12 +02:00
|
|
|
|
|
|
|
clean:
|
2022-06-29 22:04:50 +02:00
|
|
|
rm -rf md2 build
|
2022-06-29 11:40:12 +02:00
|
|
|
|
|
|
|
help:
|
2022-06-29 14:47:58 +02:00
|
|
|
@echo === Project Build Help ===
|
|
|
|
@echo
|
|
|
|
@echo Available targets:
|
|
|
|
@echo - all: build everything
|
|
|
|
@echo - clean: clean distfiles
|
|
|
|
@echo - help: show this help
|
2022-07-20 11:21:13 +02:00
|
|
|
@echo - benchmarks: run benchmarks (only works on linux!)
|
2022-06-29 11:40:12 +02:00
|
|
|
|
2022-06-29 14:47:58 +02:00
|
|
|
build/%.o: src/%.c
|
2022-07-04 18:02:34 +02:00
|
|
|
@mkdir -p build/md2_impls
|
2022-06-29 14:47:58 +02:00
|
|
|
${CC} -c ${CFLAGS} -o $@ $<
|
2022-06-29 11:40:12 +02:00
|
|
|
|
2022-06-29 14:47:58 +02:00
|
|
|
md2: ${OBJ}
|
|
|
|
${CC} -o $@ $(OBJ) ${LDFLAGS}
|
2022-06-29 11:40:12 +02:00
|
|
|
|
2022-07-20 11:21:13 +02:00
|
|
|
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 "" > $@
|
2022-07-20 11:21:57 +02:00
|
|
|
@for i in 0 2 3; do \
|
2022-07-20 11:21:13 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2022-06-29 14:47:58 +02:00
|
|
|
.PHONY: all clean help
|