-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeasure.sh
executable file
·60 lines (54 loc) · 1.36 KB
/
measure.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
#!/bin/bash
# shellcheck disable=SC2046
# shellcheck disable=SC2164
cd $(dirname "$0")
trap 'docker rm -f oracle-xe 2>&1 >/dev/null' EXIT
function startOracle() {
local image="$1"
docker rm -f oracle-xe 2>/dev/null
docker run --rm --name oracle-xe \
-p 1521:1521 -e ORACLE_PASSWORD=oracle \
-d "$image"
}
function doMeasure() {
local image="$1"
local jar=""
startOracle "$image"
if [ $? != 0 ] ; then
echo "error staring container: $image"
return
fi
jar=$(find . -path "./build/libs/*all.jar"|tr -d " "|head)
if [[ "$jar" == "" || ! -f "$jar" ]] ; then
./gradlew clean build
jar=$(find . -path "./build/libs/*all.jar"|head)
fi
java -jar "$jar" '{}'
}
function measure() {
local image="$1"
local size=0
local n=0
n=$(docker images "$image" | wc -l)
if [ "$n" != 2 ] ; then
docker pull "$image" >&2
fi
size=$(docker images --format "{{.Size}}" "$image" | sed -e "s/[GM]/ &/")
printf "%-48s: " "$image ($size)"
time=$(doMeasure "$1" | \
grep "Connection established after" | \
sed -e "s/.*established after *//;s/seconds/s/")
if [ "$time" == "" ] ; then
time="?"
fi
echo "$time"
}
if [ $# == 1 ] ; then
docker images --format "$1 ({{.Size}})" "$1" | sed -e "s/[GM]/ &/"
doMeasure "$1"
else
measure "wnameless/oracle-xe-11g-r2:latest"
measure "gvenzl/oracle-xe:11-slim"
measure "gvenzl/oracle-xe:slim"
measure "gvenzl/oracle-xe:11-full"
fi