#---*- Makefile -*-------------------------------------------------------------
#$Author: antanas $
#$Date: 2019-11-15 20:10:14 +0200 (Fri, 15 Nov 2019) $
#$Revision: 7425 $
#$URL: svn+ssh://www.crystallography.net/home/coder/svn-repositories/cod-tools/tags/v3.8.1/makefiles/Makelocal-benchmark $
#------------------------------------------------------------------------------
#*
#  Benchmarks a script.
#**

# The following variables should be predefined in the Makeconf file:
# ${BENCH_SCRIPT}
#                   Full path to the benchmarked script.
# ${BENCH_DEPEND}
#                   Additional dependencies that should be assembled
#                   before carrying out the benchmarking.
# ${BENCH_FILES}
#                   List of files that should be used for the benchmarking.

BENCH_SCRIPT ?=
BENCH_DEPEND ?=
BENCH_FILES  ?= ${wildcard *.inp}

SHELL = /bin/bash

.PHONY: all run times

all:

${BENCH_SCRIPT}: | ${BENCH_DEPEND}

run: ${BENCH_SCRIPT} ${BENCH_FILES}
	@for file in ${BENCH_FILES}; do \
	( \
		echo === $$file ===; \
		set -x; \
		${BENCH_SCRIPT} < $$file \
	); \
	done

times: ${BENCH_SCRIPT} ${BENCH_FILES}
	@for file in ${BENCH_FILES}; do \
	( \
		echo === $$file ===; \
		set -x; \
		time ${BENCH_SCRIPT} < $$file \
	); \
	done
