summaryrefslogtreecommitdiff
path: root/test/ragel.d/perftest
blob: d782bb2851a3896489366e4e3e6ece7331035088 (plain)
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
#!/bin/bash
#

set -e

ragel1=$1
ragel2=$2
targ_time=$3
shift 3

cases="$@"
if test -z "$cases"; then
	cases="mailbox1 strings1 strings2 rlscan cppscan1"
fi

CFLAGS="-O3 -Wall -Wno-unused-but-set-variable -Wno-unused-variable"

tc()
{
	ragel=$1
	compiler=$2
	seconds=$3
	root=$4

	$ragel -F1 -o $root.cpp $root.rl
	$compiler $CFLAGS -DPERF_TEST -I../aapl -DS=${seconds}ll -o $root.bin $root.cpp
	( time ./$root.bin ) 2>&1 | \
		awk '/user/ { split( $2, a, "[ms]" ); printf( "%.3f\n", a[1] * 60 + a[2] ); }'
}

for c in $cases; do
	time1=`tc $ragel1 g++ $targ_time $c`
	time2=`tc $ragel2 g++ $targ_time $c`
	speedup=`awk "BEGIN { printf( \"%.5f\n\", $time1 / $time2 ); }"`

	echo -e "$c\t$time1 -> $time2\t$speedup" | expand -12,30
done