2023-06-11 00:24:03 +00:00
# Interface:
# make
# make build
# make run
# make time-linux
# make install
# make format
# make time-linux-simple
# make profile-linux
SRC = samples.lua
2023-06-11 01:31:13 +00:00
# INTERPETER=lua# < original
INTERPETER = luajit# < faster
2023-06-11 00:24:03 +00:00
run : $( SRC )
2023-06-11 01:31:13 +00:00
$( INTERPETER) $( SRC)
2023-06-11 00:24:03 +00:00
time-linux :
@echo "Requires /bin/time, found on GNU/Linux systems" && echo
2023-06-11 01:31:13 +00:00
@echo " Running 100x and taking avg time of: $( INTERPETER) $( SRC) "
@t= $$ ( /usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(INTERPETER) $(SRC); done' 2>& 1 >/dev/null | grep real | awk '{print $$2}' ) ; echo " scale=2; 1000 * $$ t / 100 " | bc | sed "s|^|Time: |" | sed 's|$$|ms|' && echo
2023-06-11 00:24:03 +00:00
time-linux-simple :
@echo "Requires /bin/time, found on GNU/Linux systems" && echo
2023-06-11 01:31:13 +00:00
/bin/time -f "Time: %es" $( INTERPETER) $( SRC) && echo
2023-06-11 00:24:03 +00:00
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"
2023-06-11 01:31:13 +00:00
sudo perf record $( INTERPETER) $( SRC)
2023-06-11 00:24:03 +00:00
sudo perf report
rm perf.data