-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime_all.sh
More file actions
executable file
·68 lines (57 loc) · 1.48 KB
/
time_all.sh
File metadata and controls
executable file
·68 lines (57 loc) · 1.48 KB
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
#!/bin/bash
#
# AoC time all the things of year {x}
tabs 12
year=$1
runs=10
if [ ! $1 ]
then
year=`date +"%Y"`
fi
declare -A daytotal
declare -A daybest
declare -A dayavg
declare -A dayworst
printf "\n\nRunning each day %d times\n\n" $runs
echo "Day | Best (µs) | Avg (µs) | Worst (µs)"
echo "------------+-----------+-----------+--------------"
for day in {1..25}
do
best=0
worst=0
subt=0
total=0
file="./buildoutput/d$year$day.out"
inputfile="./inputs/$year/input.day$day"
if [ -f $file ]
then
for cnt in $( eval echo {1..$runs} )
do
if [ ! -f $inputfile ]
then
retVal=`$file t`
else
retVal=`$file t < $inputfile`
fi
total=$(($total + retVal))
subt=$(($subt + retVal))
best=$((best > retVal || best == 0 ? retVal: best))
worst=$((retVal > worst || worst == 0 ? retVal: worst))
totalruntime=$(($totalruntime + retVal))
done
subt=$(($subt/$runs))
daytotal[$day]=$total
daybest[$day]=$best
dayavg[$day]=$subt
dayworst[$day]=$worst
printf "%s\t| %d\t| %d\t| %d\n" $day ${daybest[$day]} ${dayavg[$day]} ${dayworst[$day]}
totalbest=$(($totalbest+$best));
totalworst=$(($totalworst+$worst));
totalavg=$(($totalavg+$subt));
fi
done
echo "------------+-----------+-----------+--------------"
printf "Totals\t| %d\t| %d\t| %d\n\n" $totalbest $totalavg $totalworst
totalruntime=$(($totalruntime / 1000))
printf "Total time taken %d ms\n\n" $totalruntime
tabs -8