-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtime.sh
executable file
·37 lines (36 loc) · 1.33 KB
/
time.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
#!/bin/bash
avg_time() {
#
# usage: avg_time n command ...
#
n=$1; shift
(($# > 0)) || return # bail if no command given
for ((i = 0; i < n; i++)); do
{ time -p "$@" &>/dev/null; } 2>&1 # ignore the output of the command
# but collect time's output in stdout
done | awk '
/user/ { user = user + $2; nu++ }
END {
if (nu>0) printf("user %f\n", user/nu);
}'
}
# echo "test-1.txt brute force"
# avg_time 100 python main.py tests/test-1.txt
# echo "test-1.txt plane sweep"
# avg_time 100 python main.py tests/test-1.txt --plane-sweep
# echo "test-2.txt brute force"
# avg_time 100 python main.py tests/test-2.txt
# echo "test-2.txt plane sweep"
# avg_time 100 python main.py tests/test-2.txt --plane-sweep
# echo "test-3.txt brute force"
# avg_time 100 python main.py tests/test-3.txt
# echo "test-3.txt plane sweep"
# avg_time 100 python main.py tests/test-3.txt --plane-sweep
echo "test-4.txt brute force"
avg_time 100 python main.py tests/test-4.txt
echo "test-4.txt plane sweep"
avg_time 100 python main.py tests/test-4.txt --plane-sweep
# echo "test-5.txt brute force"
# avg_time 100 python main.py tests/test-5.txt
# echo "test-5.txt plane sweep"
# avg_time 100 python main.py tests/test-5.txt --plane-sweep