-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·83 lines (78 loc) · 2.83 KB
/
test.sh
File metadata and controls
executable file
·83 lines (78 loc) · 2.83 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
#############################################
# Author: Darshan Thaker #
# This script can be used to test parallel #
# vs. serial implementations. Feel free to #
# hardcode the below variables if needed. #
# #
# Preconditions: The parallel version of #
# the program takes in a number of threads #
# as its final command line parameter. The #
# program should also output a line #
# starting with 'Time:' to see how long #
# the program took. #
# #
# It will output the time taken for the old #
# version, the new version, and the speedup #
# of the program, which is defined as #
# OLD_TIME / NEW_TIME #
#############################################
echo "What is the command to compile your program (old and new)? (Ex. 'make clean all' or 'none')"
read COMPILE_COMMAND
echo "What is the command to run your old program? (Ex. './EXECUTABLE' or 'python NAME')"
read RUN_COMMAND_OLD
echo "What is the command to run your new program? (Ex. './EXECUTABLE' or 'python NAME')"
read RUN_COMMAND_NEW
echo "How many threads do you want to run (max)?"
read THREADS
echo "What is the stepsize for threads (starting from 1 thread)"
read STEP_SIZE
echo "How many inputs do you want to test?"
read INPUT_SIZE
INPUT_COUNTER=0
INPUT=()
while [ $INPUT_COUNTER -lt $INPUT_SIZE ]; do
echo "Enter in name of input #$INPUT_COUNTER"
read INP
INPUT+=($INP)
let INPUT_COUNTER=INPUT_COUNTER+1
done
TCOUNTER=1
INPUT_COUNTER=0
if [ $COMPILE_COMMAND != "none" ]
then
$COMPILE_COMMAND
if [ $? -ne 0 ]
then
echo "Did not compile properly: return value nonzero"
exit
fi
fi
if [ $INPUT_SIZE -ne 0 ]
then
while [ $INPUT_COUNTER -lt $INPUT_SIZE ]; do
while [ $TCOUNTER -lt $THREADS ]; do
echo "Input: ${INPUT[$INPUT_COUNTER]}, Number of threads: $TCOUNTER"
OLDTIMETAKEN="$($RUN_COMMAND_OLD ${INPUT[$INPUT_COUNTER]} | grep "Time:")"
NEWTIMETAKEN="$($RUN_COMMAND_NEW ${INPUT[$INPUT_COUNTER]} $TCOUNTER | grep "Time:")"
echo "OLD: $OLDTIMETAKEN"
echo "NEW: $NEWTIMETAKEN"
echo "SPEEDUP: "
python -c "print $OLDTIMETAKEN / float($NEWTIMETAKEN)"
let TCOUNTER=TCOUNTER+$STEP_SIZE
done
TCOUNTER=1
let INPUT_COUNTER=INPUT_COUNTER+1
done
else
while [ $TCOUNTER -lt $THREADS ]; do
echo "Number of threads: $TCOUNTER"
OLDTIMETAKEN="$($RUN_COMMAND_OLD | grep "Time:")"
NEWTIMETAKEN="$($RUN_COMMAND_NEW $TCOUNTER | grep "Time:")"
echo "OLD: $OLDTIMETAKEN"
echo "NEW: $NEWTIMETAKEN"
echo "SPEEDUP: "
python -c "print $OLDTIMETAKEN / float($NEWTIMETAKEN)"
let TCOUNTER=TCOUNTER+$STEP_SIZE
done
fi