-
Notifications
You must be signed in to change notification settings - Fork 0
/
executionTime.sh
executable file
·37 lines (29 loc) · 1.05 KB
/
executionTime.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
# Compiles given .ws file, executes it multiple times and prints average execution time.
# It's intended to be used during optimization to compare different implementations.
# Problem: cannot handle programs which take input
#!/usr/bin/env bash
echo "Please enter the filename without extension (a .ws file is expected)"
read filename
python3 wsCompiler.py $filename.ws
nasm -fmacho64 $filename.asm && ld $filename.o
echo "Does" $filename "use input? (enter 'yes' if so)"
read hasinput
if [ $hasinput = yes ]
then
echo "Please enter the .exp program that handles your input"
read filenameexp
start=$(python -c 'import time; print time.time()')
for value in {1..5000}
do
[$filenameexp] &>/dev/null # run without showing the output
done
else
start=$(python -c 'import time; print time.time()')
for value in {1..5000}
do
[./a.out] &>/dev/null # run without showing the output
done
fi
dur=$(echo "($(python -c 'import time; print time.time()') - $start)/10000" | bc -l)
echo "Average execution time:"
echo $dur