2023-10-14 18:59:56 +00:00
# Compiler
2023-10-15 00:46:52 +00:00
OC = ocamlopt
2023-10-14 18:59:56 +00:00
# ocamlopt: platform-specific, faster
# ocamlc: platform-independent intermediate representation, run with ocamlrun
2023-10-15 00:46:52 +00:00
FAST = -O3 -unsafe # install flambda with opam
2023-10-15 01:08:42 +00:00
PROF = -g
2023-10-14 18:59:56 +00:00
SRC = samples.ml
2023-10-15 00:19:56 +00:00
OUT = ./out/samples
2023-10-14 18:59:56 +00:00
build : $( SRC )
2023-10-15 00:46:52 +00:00
$( OC) $( SRC) -o $( OUT)
2023-10-14 19:12:42 +00:00
mv samples.cmi samples.cmx samples.o ./out/
run :
2023-10-15 00:19:56 +00:00
$( OUT)
2023-10-15 00:46:52 +00:00
fast :
$( OC) $( FAST) $( SRC) -o $( OUT)
mv samples.cmi samples.cmx samples.o ./out/
2023-10-15 00:19:56 +00:00
time :
bash -c " time $( OUT) "
2023-10-15 00:46:52 +00:00
2023-11-19 18:11:41 +00:00
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 ./out/samples; 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-10-15 01:08:42 +00:00
profile :
$( OC) $( PERF) $( SRC) -o $( OUT)
mv samples.cmi samples.cmx samples.o ./out/
sudo perf record -g $( OUT)
sudo perf report
rm perf.data
2023-10-15 00:46:52 +00:00
switch-opam-fast :
opam switch create 4.11.2+flambda
eval $( opam env)
switch-opam-5.1.0 :
opam switch create 5.1.0
eval $( opam env)