forked from bitdefender/bddisasm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark.sh
executable file
·60 lines (48 loc) · 1.3 KB
/
benchmark.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
set -e
if [ "$#" -ne 4 ] ; then
echo "Compare the speed of two different disasmtool versions"
echo "Usage $0 <first disasmtool> <second disasmtool> <input file> <iterations>"
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
if [ "$COUNT" -lt 3 ] ; then
echo "ministat requires at least 3 samples"
exit 1
fi
FIRSTRESULT="$FIRST.result"
SECONDRESULT="$SECOND.result"
truncate -s 0 $FIRSTRESULT
truncate -s 0 $SECONDRESULT
# 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 $FIRSTRESULT
$SECOND -f $INPUT -nv -iv | tee -a $SECONDRESULT
done
ministat -C 6 $FIRSTRESULT $SECONDRESULT
echo 'Instructions/second, higher is better'
if [ "$COUNT" -lt 30 ] ; then
echo "Sample count $COUNT was less than 30, results might be unreliable"
fi