-
Notifications
You must be signed in to change notification settings - Fork 1
/
umbrella_multiple_no_cache.sh
executable file
·70 lines (54 loc) · 1.88 KB
/
umbrella_multiple_no_cache.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
#!/bin/bash
CONTAINER_NAME="povray"
OUTPUT_FILE_NAME="output-$(date +%j-%H-%M-%S).csv"
FRAME_FILE_SUFFIX="$(date +%j-%H-%M-%S).png"
NBR_LOOPS=$1
DOCKER_IMAGE=$2
# test if the number of loops to execute is less than 1
if [[ "$NBR_LOOPS" -lt "1" || "$NBR_LOOPS" == "" ]] ; then
echo "==> error: the number of loops should be bigger that 1"
exit 1
fi
# simple test of docker image
if [[ "$DOCKER_IMAGE" == "" ]] ; then
echo "==> error: a docker image should be specified"
exit 1
fi
# install wget
if [[ "$(which apt-get)" != "" ]] ; then
DEBIAN_FRONTEND=noninteractive apt-get install wget -y
elif [[ "$(which apk)" != "" ]] ; then
apk add --update --no-cache wget
elif [[ "$(which yum)" != "" ]] ; then
yum -y install wget
fi
# create new output file
touch $OUTPUT_FILE_NAME
# start the test
echo "==> do $NBR_LOOPS loops"
START_TIME_TOTAL=$SECONDS
for i in $(seq $NBR_LOOPS) ; do
# start counter
START_TIME_TEST=$SECONDS
# always download datasets
wget https://curate.nd.edu/downloads/7h149p3117b -O WRC_RubiksCube.inc
wget https://curate.nd.edu/downloads/7d278s47r65 -O 4_cubes.pov
# pull a latest PovRAY docker image
docker pull $DOCKER_IMAGE
# run the test
docker run -it --rm --name $CONTAINER_NAME -v $PWD:/src $DOCKER_IMAGE /bin/bash -c "cd /src; ls -l; povray +I4_cubes.pov +Oframe-$i-$FRAME_FILE_SUFFIX +K.0 -H7500 -W7500; exit 0"
# remove docker container and image
#docker rm -f $CONTAINER_NAME > /dev/null
# comment this line to use local cache
docker rmi $DOCKER_IMAGE
rm WRC_RubiksCube.inc 4_cubes.pov
# stop counter
ELAPSED_TIME=$(($SECONDS - $START_TIME_TEST))
# display time
echo "==> loop $i | elapsed time (s): $ELAPSED_TIME"
# write time in output file
echo "$i $ELAPSED_TIME" >> $OUTPUT_FILE_NAME
done
# display final message
echo "==> number of loops: $NBR_LOOPS"
echo "==> total time: $(($SECONDS - $START_TIME_TOTAL)) seconds"