-
Notifications
You must be signed in to change notification settings - Fork 21
/
benchmark.sh
executable file
·51 lines (46 loc) · 1.01 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
#!/bin/sh
# Syntax: "./benchmark.sh [-t] {profile}
#
# This script requires bash 4.0+ and awk
#
if [ "$1" == '-t' ];
then
SHOW_ONLY_TIME=true;
else
SHOW_ONLY_TIME=false;
fi
if [ "$SHOW_ONLY_TIME" == 'true' ];
then
PROFILE="$2";
else
PROFILE="$1";
fi
if [ "$PROFILE" == '' ];
then
echo 'Bad syntax: "./benchmark.sh [-t] {profile}"'
exit 1;
fi
OUTPUT_FILE_DATE_SUFFIX=`date +"%Y%m%d%H%M%S"`
OUTPUT_FILE_RANDOM_SUFFIX=`date | md5sum | cut -c1-6`
OUTPUT_FILE="benchmark-output-$PROFILE-$OUTPUT_FILE_DATE_SUFFIX-$OUTPUT_FILE_RANDOM_SUFFIX"
COMMAND="mvn -P $PROFILE clean compile test -Dtest=org.thymeleaf.benchmark.BenchmarkTest"
if [ "$SHOW_ONLY_TIME" == 'false' ];
then
echo "
Executing benchmark using profile: $PROFILE
"
$COMMAND;
else
EXPR='.*\[THYMELEAF\]\[\(.*\)\]\[.*'
$COMMAND > $OUTPUT_FILE;
OUTPUT=`cat $OUTPUT_FILE`
TIME=$((`expr match "$OUTPUT" "$EXPR"`))
if [ "$TIME" == "0" ];
then
$(mv $OUTPUT_FILE "$OUTPUT_FILE-error.log")
echo 0
exit 1
fi
rm $OUTPUT_FILE
echo $TIME
fi