-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark
executable file
·57 lines (47 loc) · 1.39 KB
/
benchmark
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
#!/bin/bash
#
# 2013-11-17: Frederick Ceder
#
if [[ $# < 4 ]]
then
echo "Usage: benchmark <command> <input-file> <repeats> <thread_count>"
echo "Usage: benchmark <command> <input-file> <repeats> <thread_count> <anything_to_remove_old_outdata>"
echo ""
exit 0
fi
command=$1
inputfile=$2
repeats=$3
numthreads=$4
output_file='benchmark_results_'${command##*/}'.csv'
output_dir="output/"
output_file=$output_dir$output_file
TIMEFORMAT='%3R'
mkdir -p $output_dir
if [[ $# > 4 ]]
then
# in this case we remove the old *.csv
rm ${output_dir}*.csv
fi
echo "Outputting to file: "$output_file
echo ""
command_to_run="${command} ${numthreads} ${inputfile}"
# --------------------------------------------------------------------------
# Benchmark loop
# --------------------------------------------------------------------------
echo 'Benchmarking ' $command_to_run '...';
# Indicate the command we just run in the csv file
echo '======' $command_to_run '======' >> $output_file;
# Run the given command [repeats] times
for (( i = 1; i <= $repeats ; i++ ))
do
# percentage completion
p=$(( $i * 100 / $repeats))
# indicator of progress
l=$(seq -s "+" $i | sed 's/[0-9]//g')
(time $command_to_run) > /dev/null 2>> $output_file
echo -ne ${l}' ('${p}'%) \r'
done
echo -ne '\n'
# Convenience seperator for file
# echo '-----------------------------------------' >> $output_file