time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

commit 2bc028b29c5032e7ffb8424511b146cad383d296
parent d1013758c83d3edad794027d62660ff883a9026a
Author: NunoSempere <nuno.sempere@protonmail.com>
Date:   Sat, 10 Jun 2023 18:19:10 -0600

add makefile template

Diffstat:
Awip/template/makefile | 49+++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+), 0 deletions(-)

diff --git a/wip/template/makefile b/wip/template/makefile @@ -0,0 +1,49 @@ +# Interface: +# make +# make build +# make run +# make time-linux +# make install +# make format +# make time-linux-simple +# make profile-linux + +# Main file +SRC=samples.lang +OUTPUT=out/samples + +# Compiler +COMPILER=lang-compiler +FLAGS= + +## Formatter +FORMATTER=lang-formatter --options + +## make build +build: $(SRC) + $(COMPILER) $(FLAGS) -o $(OUTPUT) + +install: + lang-package-manager install dependencies + +format: $(SRC) + $(FORMATTER) $(SRC) + +run: $(SRC) $(OUTPUT) + ./$(OUTPUT) + +time-linux: + @echo "Requires /bin/time, found on GNU/Linux systems" && echo + @echo "Running 100x and taking avg time of: $(OUTPUT)" + @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time: |" | sed 's|$$|ms|' && echo + +time-linux-simple: + @echo "Requires /bin/time, found on GNU/Linux systems" && echo + /bin/time -f "Time: %es" ./$(OUTPUT) && echo + +profile-linux: + @echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar" + @echo "Must be run as sudo" + sudo perf record $(OUTPUT) + sudo perf report + rm perf.data