############################################################################### SHELL != which bash .ONESHELL: ############################################################################### BUG = cas CPU != grep -m 1 "cpu cores" /proc/cpuinfo | grep -o '[[:digit:]]*' SEQ = empty exceptions optional SUB = $(sort $(filter-out $(BUG),$(shell find * -maxdepth 0 -type d))) TXT = $(foreach i,$(SUB),$i/stack.txt) ############################################################################### all: @if make -qs $(TXT); then make -s sort else make -s stat fi att: -@find $(SUB) -maxdepth 1 -mindepth 1 -name makefile -execdir make -s $@ \; check: -@find $(SUB) -maxdepth 1 -mindepth 1 -name makefile -execdir make -s $@ \; 2> /dev/null clave: @printf '%68s\n' | tr ' ' '-' echo 'clave:' printf '%68s\n' | tr ' ' '-' echo ' programa: símbolo final indica "." = secuencia o ":" = paralelo' echo ' median: mediana' echo ' mean: media aritmética' echo ' stddev: desviación típica' echo ' cpu: tiempo de cpu en segundos' echo ' ratio: mediana / cpu' clean: -rm -fv core.* *~ -find -mindepth 2 -maxdepth 2 -iname makefile -execdir make $@ \; cpu: n$(CPU) 10ms all default: cpu min: n1 10ms all n%: @find $(filter-out $(SEQ),$(SUB)) -name stack.cc -execdir sed --follow-symlinks -i 's/const size_t N = .*;/const size_t N = $*;/' {} \; sort: $(TXT) | clave @declare -a F=(program median mean stdev cpu ratio) declare -a R=('-b' '-r' '-r' '-s' '-s' '-r') for ((i=0; i<$${#F[@]}; ++i)); do printf '%68s\n' | tr ' ' '-' head -n 1 -q $< | sed "s/ $${F[$$i]}/\[$${F[$$i]}\]/" printf '%68s\n' | tr ' ' '-' for t in $^; do tail -n 1 $$t done | sort -k$$((i+1)),$$((i+1)) -k$${#F[@]},$${#F[@]} $${R[$$i]} done printf '%68s\n' | tr ' ' '-' stat: $(SUB) | clave @for i in $^; do make -C $$i -s txt &> /dev/null if [ "$$i" == "$<" ]; then printf '%68s\n' | tr ' ' '-' head -n 1 $$i/stack.txt printf '%68s\n' | tr ' ' '-' fi tail -n 1 $$i/stack.txt done printf '%68s\n' | tr ' ' '-' test: $(EXE) -@find $(SUB) -maxdepth 1 -mindepth 1 -name test -execdir {} \; 1> /dev/null %ms: @find -name stack.cc -execdir sed --follow-symlinks -i 's/std::this_thread::sleep_for(.*ms);/std::this_thread::sleep_for($*ms);/' {} \; ############################################################################### %.txt: %.cc @make -C $$(dirname $@) -s $$(basename $@) | grep -v stdev ############################################################################### .PHONY: all att check clave clean cpu default min n% sort stat %ms ###############################################################################