Include the source filename in the benchmark output; in a preparation for easy automated re-runs and summary of the tests

master
Ivan Zahariev 2016-09-06 23:29:08 +03:00
parent 902a520eb5
commit f3edfca18c
1 changed files with 26 additions and 16 deletions

42
run.sh
View File

@ -12,6 +12,7 @@ function run_benchmark() {
RUN_CMD="$3"
VERSION_CMD="$4"
VERSION_FILTER_CMD="$5"
SRC_FILE="$6"
$VERSION_CMD >/dev/null 2>&1
if [ "$?" == 127 ]; then # "command not found"
@ -57,27 +58,36 @@ function run_benchmark() {
exit 1
fi
echo "$TIMES_OUT nlines:$NLINES run_try:$n header:'$HEADER' version:'$VERSION_OUT'"
echo "$TIMES_OUT nlines:$NLINES run_try:$n "\
"header:'$HEADER' version:'$VERSION_OUT' src_file:$SRC_FILE"
done
}
C='g++' ; run_benchmark 'C++ (optimized with -O2)' "$C -Wall -O2 primes.cpp -o primes.cpp.out" './primes.cpp.out' "$C --version" 'head -n1'
C='g++' ; SRC='primes.cpp' ; run_benchmark 'C++ (optimized with -O2)' "$C -Wall -O2 $SRC -o primes.cpp.out" './primes.cpp.out' "$C --version" 'head -n1' "$SRC"
rm -f ./primes.cpp.out
C='g++' ; run_benchmark 'C++ (not optimized)' "$C -Wall primes.cpp -o primes.cpp.out" './primes.cpp.out' "$C --version" 'head -n1'
C='g++' ; SRC='primes.cpp' ; run_benchmark 'C++ (not optimized)' "$C -Wall $SRC -o primes.cpp.out" './primes.cpp.out' "$C --version" 'head -n1' "$SRC"
rm -f ./primes.cpp.out
C='go' ; run_benchmark 'Go (not optimized, default compiler)' "$C build primes.go" './primes' "$C version" 'cat'
C='go' ; SRC='primes.go' ; run_benchmark 'Go (not optimized, default compiler)' "$C build $SRC" './primes' "$C version" 'cat' "$SRC"
go clean
C='pypy' ; run_benchmark 'PyPy 2.7' 'true' "$C ./primes.py" "$C -V" 'cat'
C='python2.7' ; run_benchmark 'Python 2.7' 'true' "$C ./primes.py" "$C -V" 'cat'
C='python3.2' ; run_benchmark 'Python 3.2' 'true' "$C ./primes.py" "$C -V" 'cat'
C='python3.5' ; run_benchmark 'Python 3.5' 'true' "$C ./primes.py" "$C -V" 'cat'
C='perl' ; run_benchmark 'Perl' 'true' "$C ./primes.pl" "$C -v" 'grep built'
C='php5.6' ; run_benchmark 'PHP 5.6' 'true' "$C ./primes.php" "$C -v" 'head -n1'
C='php7.0' ; run_benchmark 'PHP 7.0' 'true' "$C ./primes.php" "$C -v" 'head -n1'
C='javac' ; run_benchmark 'Java (std)' "$C primes.java" 'java PrimeNumbersBenchmarkApp' "$C -version" 'cat'
C='pypy' ; SRC='primes.py' ; run_benchmark 'PyPy 2.7' 'true' "$C $SRC" "$C -V" 'cat' "$SRC"
C='python2.7' ; SRC='primes.py' ; run_benchmark 'Python 2.7' 'true' "$C $SRC" "$C -V" 'cat' "$SRC"
C='python3.2' ; SRC='primes.py' ; run_benchmark 'Python 3.2' 'true' "$C $SRC" "$C -V" 'cat' "$SRC"
C='python3.5' ; SRC='primes.py' ; run_benchmark 'Python 3.5' 'true' "$C $SRC" "$C -V" 'cat' "$SRC"
C='perl' ; SRC='primes.pl' ; run_benchmark 'Perl' 'true' "$C $SRC" "$C -v" 'grep built' "$SRC"
C='php5.6' ; SRC='primes.php' ; run_benchmark 'PHP 5.6' 'true' "$C $SRC" "$C -v" 'head -n1' "$SRC"
C='php7.0' ; SRC='primes.php' ; run_benchmark 'PHP 7.0' 'true' "$C $SRC" "$C -v" 'head -n1' "$SRC"
C='javac' ; SRC='primes.java' ; run_benchmark 'Java (std)' "$C $SRC" 'java PrimeNumbersBenchmarkApp' "$C -version" 'cat' "$SRC"
rm -f PrimeNumbersBenchmarkApp.class PrimeNumbersGenerator.class
C='javac' ; run_benchmark 'Java (non-std)' "$C primes-non-std-lib.java" 'java PrimeNumbersBenchmarkApp' "$C -version" 'cat'
C='javac' ; SRC='primes-alt.java' ; run_benchmark 'Java (non-std)' "$C $SRC" 'java PrimeNumbersBenchmarkApp' "$C -version" 'cat' "$SRC"
rm -f PrimeNumbersBenchmarkApp.class PrimeNumbersGenerator.class IntList.class
C='node' ; run_benchmark 'JavaScript (nodejs)' 'true' "$C ./primes.js" "$C -v" 'cat'
C='nodejs' ; run_benchmark 'JavaScript (nodejs)' 'true' "$C ./primes.js" "$C -v" 'cat'
C='ruby' ; run_benchmark 'Ruby' 'true' "$C ./primes.rb" "$C -v" 'cat'
# Node.js has two different binary names; try both of them
C='node' ; SRC='primes.js' ; run_benchmark 'JavaScript (nodejs)' 'true' "$C $SRC" "$C -v" 'cat' "$SRC"
C='nodejs' ; SRC='primes.js' ; run_benchmark 'JavaScript (nodejs)' 'true' "$C $SRC" "$C -v" 'cat' "$SRC"
C='ruby' ; SRC='primes.rb' ; run_benchmark 'Ruby' 'true' "$C $SRC" "$C -v" 'cat' "$SRC"