-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark.sh
108 lines (87 loc) · 2.12 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
#
# e.g:
# seq 1 10 | xargs -I{} ./benchmark.sh SanitisedNet471 50 &&
# seq 1 10 | xargs -I{} ./benchmark.sh OrchardCore 50 &&
# seq 1 10 | xargs -I{} ./benchmark.sh orleans 50
#
SLN=$1
REPEATS=${2:-50}
mytime=$(date -u)
mydir=$(realpath "`dirname \"$0\"`")
results0=$mydir/"results0.txt"
results1=$mydir/"results1.txt"
global=$mydir/"global.json"
global0=$mydir/"global0.json"
global1=$mydir/"global1.json"
# Makes sure that there are no dangling dotnet processes left after each restore
export MSBUILDDISABLENODEREUSE=1
# exit when any command fails
set -e
# Read the dotnet version
cp $global0 $global
version0=$(cd $mydir/$SLN && dotnet --version)
cp $global1 $global
version1=$(cd $mydir/$SLN && dotnet --version)
# Insert test run markers
echo "Starting the benchmark. mydir=$mydir, SLN=$SLN, Version=$version0, Repeats=$REPEATS, Time=$mytime" >> $results0
echo "Starting the benchmark. mydir=$mydir, SLN=$SLN, Version=$version1, Repeats=$REPEATS, Time=$mytime" >> $results1
dt=0
dt0=0
dt1=0
i=0
while [[ $i -le $REPEATS ]]
do
if [ $i -gt 0 ]
then
eta=$(echo "($dt0 + $dt1) * ($REPEATS - $i + 1)"| bc)
echo "$i, $dt0, $dt1, ETA:$eta"
else
echo "warmup run"
fi
##############
# Prepare 0
##############
cp $global0 $global
(cd $mydir/$SLN && git clean -fxd) >> /dev/null
sleep 5
##############
# Measure 0
##############
starttime0=$(date +%s.%N)
##############
# Command 0
##############
(cd $mydir/$SLN && dotnet restore -clp:summary) >> /dev/null
endtime0=$(date +%s.%N)
dt0=$(echo "$endtime0 - $starttime0" | bc)
if [ $i -gt 0 ]
then
echo "$dt0" >> $results0
else
echo "warmup run:$dt0" >> $results0
fi
##############
# Prepare 1
##############
cp $global1 $global
(cd $mydir/$SLN && git clean -fxd) >> /dev/null
sleep 5
##############
# Measure 1
##############
starttime1=$(date +%s.%N)
##############
# Command 1
##############
(cd $mydir/$SLN && dotnet restore -clp:summary) >> /dev/null
endtime1=$(date +%s.%N)
dt1=$(echo "$endtime1 - $starttime1" | bc)
if [ $i -gt 0 ]
then
echo "$dt1" >> $results1
else
echo "warmup run:$dt1" >> $results1
fi
let i=i+1
done