forked from ebarlas/java-httpserver-vthreads
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.sh
More file actions
executable file
·47 lines (38 loc) · 931 Bytes
/
profile.sh
File metadata and controls
executable file
·47 lines (38 loc) · 931 Bytes
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
#!/bin/bash
set -e
getCurrentTime() {
date +"%s.%3N"
}
runHttpServer() {
./httpsrvimg/bin/java -Dsun.net.httpserver.nodelay=true -m httpsrv/httpsrv.Hello
}
profileHttpServer() {
read line # wait for "ready" line emitted by server
local javaEndTime=$(getCurrentTime)
local statusCode=$(makeCurlRequest)
local curlEndTime=$(getCurrentTime)
echo "$1 $javaEndTime $curlEndTime $statusCode"
pkill java
}
makeCurlRequest() {
curl "http://localhost:8080/" -o /dev/null -s -w "%{http_code}"
}
measureExecutionTimes() {
for i in {1..10}; do
local startTime=$(getCurrentTime)
runHttpServer | profileHttpServer $startTime
done | processTimings
}
processTimings() {
awk '{
d1=$2-$1
d2=$3-$1
s1+=d1
s2+=d2
printf "%f, %f, %d\n", d1, d2, $4
}
END {
printf "---\n%f, %f\n", s1/NR, s2/NR
}'
}
measureExecutionTimes