From c611c8aed53e25a516d304fab36006c8cd4217ff Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 6 Aug 2024 19:13:06 +0300 Subject: [PATCH] Add benchmark script --- benchmark.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 benchmark.sh diff --git a/benchmark.sh b/benchmark.sh new file mode 100755 index 0000000..3ac01d6 --- /dev/null +++ b/benchmark.sh @@ -0,0 +1,52 @@ +#!/bin/sh +set -e + +if [ "$#" -ne 4 ] ; then + echo "Compare the speed of two different disasmtool versions" + echo "Usage $0 " + exit 0 +fi + +FIRST=$1 +SECOND=$2 +INPUT=$3 +COUNT=$4 + +if [ ! -x "$FIRST" ] ; then + echo "First program $FIRST does not exist or is not executable" + exit 1 +fi + +if [ ! -x "$SECOND" ] ; then + echo "Second program $SECOND does not exist or is not executable" + exit 1 +fi + +if [ ! -f "$INPUT" ] ; then + echo "Input file $INPUT does not exist" + exit 1 +fi + +case $COUNT in + ''|*[!0-9]*) echo "Iteration count $COUNT is not a number" ; exit 1 ;; + *) ;; +esac + +truncate -s 0 before.txt +truncate -s 0 after.txt + +# Make sure all necessary files are in cache +$FIRST -f $INPUT -nv > /dev/null +$SECOND -f $INPUT -nv > /dev/null + +for n in `seq 1 $COUNT` ; do + echo "$n" + $FIRST -f $INPUT -nv -iv | tee -a before.txt + $SECOND -f $INPUT -nv -iv | tee -a after.txt +done + +ministat -C 6 before.txt after.txt +echo 'Instructions/second, higher is better' +if [ "$COUNT" -ne 30 ] ; then + echo "Sample count $COUNT was less than 30, results might be unreliable" +fi