2023-06-26 17:44:41 +00:00
# Interface:
# make
# make build
# make format
# make run
# Compiler
CC = gcc
# CC=tcc # <= faster compilation
# Main file
2023-07-16 19:00:30 +00:00
SRC = example.c ../../squiggle.c
2023-06-26 17:44:41 +00:00
OUTPUT = example
## Dependencies
MATH = -lm
## Flags
DEBUG = #'-g'
STANDARD = -std= c99
WARNINGS = -Wall
OPTIMIZED = -O3 #-Ofast
# OPENMP=-fopenmp
## Formatter
STYLE_BLUEPRINT = webkit
FORMATTER = clang-format -i -style= $( STYLE_BLUEPRINT)
## make build
build : $( SRC )
$( CC) $( OPTIMIZED) $( DEBUG) $( SRC) $( MATH) -o $( OUTPUT)
format : $( SRC )
$( FORMATTER) $( SRC)
run : $( SRC ) $( OUTPUT )
2023-08-17 12:30:33 +00:00
./$( OUTPUT) && echo
2023-06-26 17:44:41 +00:00
time-linux :
@echo "Requires /bin/time, found on GNU/Linux systems" && echo
@echo " Running 100x and taking avg time $( OUTPUT) "
2023-08-17 12:30:33 +00:00
@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 using 1 thread: |" | sed 's|$$|ms|' && echo
2023-06-26 17:44:41 +00:00
## Profiling
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"
$( CC) $( SRC) $( MATH) -o $( OUTPUT)
2023-07-22 19:49:00 +00:00
sudo perf record ./$( OUTPUT)
2023-06-26 17:44:41 +00:00
sudo perf report
rm perf.data