-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProveParallelismTest.sh
executable file
·80 lines (65 loc) · 2.52 KB
/
ProveParallelismTest.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
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
#!/bin/bash
set -euxo pipefail
if [[ $# -lt 1 ]]; then
echo "Usage: ${0} <<IP address of prime challenge server>>"
exit 1
fi
PRIME_SERVER="${1}"
STARTTIME=$(date +%s)
# Serial request #1
jobid=$(curl --request POST "http://${PRIME_SERVER}:8080/Start/1,1234571")
echo ${jobid}
until ! curl --request GET "http://${PRIME_SERVER}:8080/Query/${jobid}" -v 2>&1 | grep "HTTP/1.0 204"; do
printf '.'
sleep 1
done
curl --request GET "http://${PRIME_SERVER}:8080/Query/${jobid}"
# Serial request #2
jobid=$(curl --request POST "http://${PRIME_SERVER}:8080/Start/1,1234572")
echo ${jobid}
until ! curl --request GET "http://${PRIME_SERVER}:8080/Query/${jobid}" -v 2>&1 | grep "HTTP/1.0 204"; do
printf '.'
sleep 1
done
curl --request GET "http://${PRIME_SERVER}:8080/Query/${jobid}"
# Serial request #3
jobid=$(curl --request POST "http://${PRIME_SERVER}:8080/Start/1,1234573")
echo ${jobid}
until ! curl --request GET "http://${PRIME_SERVER}:8080/Query/${jobid}" -v 2>&1 | grep "HTTP/1.0 204"; do
printf '.'
sleep 1
done
curl --request GET "http://${PRIME_SERVER}:8080/Query/${jobid}"
ENDTIME=$(date +%s)
serial_duration=$(($ENDTIME - $STARTTIME))
echo "It took ${serial_duration} seconds get 3 sets of prime numbers serially"
STARTTIME=$(date +%s)
# Parallel requests
jobid1=$(curl --request POST "http://${PRIME_SERVER}:8080/Start/1,1234581")
jobid2=$(curl --request POST "http://${PRIME_SERVER}:8080/Start/1,1234582")
jobid3=$(curl --request POST "http://${PRIME_SERVER}:8080/Start/1,1234583")
echo ${jobid1}
echo ${jobid3}
echo ${jobid2}
# Wait for parallel request #1
until ! curl --request GET "http://${PRIME_SERVER}:8080/Query/${jobid1}" -v 2>&1 | grep "HTTP/1.0 204"; do
printf '.'
sleep 1
done
curl --request GET "http://${PRIME_SERVER}:8080/Query/${jobid1}"
# Wait for parallel request #2
until ! curl --request GET "http://${PRIME_SERVER}:8080/Query/${jobid2}" -v 2>&1 | grep "HTTP/1.0 204"; do
printf '.'
sleep 1
done
curl --request GET "http://${PRIME_SERVER}:8080/Query/${jobid2}"
# Wait for parallel request #3
until ! curl --request GET "http://${PRIME_SERVER}:8080/Query/${jobid3}" -v 2>&1 | grep "HTTP/1.0 204"; do
printf '.'
sleep 1
done
curl --request GET "http://${PRIME_SERVER}:8080/Query/${jobid3}"
ENDTIME=$(date +%s)
parallel_duration=$(($ENDTIME - $STARTTIME))
echo "It took ${parallel_duration} seconds get 3 sets of prime numbers in parallel"
echo "${parallel_duration} should be around 60% or less of ${serial_duration} *if* you have 4 or more cores/CPUs on the PrimeChallenge server"