Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
flyimg/benchmark.sh
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
42 lines (32 sloc)
1008 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# check if vegeta installed | |
vegeta -version >/dev/null 2>&1 || { echo >&2 "Benchmark require Vegeta but it's not installed. Aborting."; exit 1; } | |
# which port | |
port=8080 | |
# a random name for the container and the image | |
randName=$(LC_CTYPE=C tr -dc "[:lower:]" < /dev/random | head -c 8) | |
# build the image | |
docker build -t "$randName" . | |
# run the container | |
docker run -itd -p $port:80 --name "$randName" "$randName" | |
# sleep 2 sec until the container is ready | |
sleep 2 | |
# install php dependencies | |
docker exec "$randName" composer install --no-dev --optimize-autoloader | |
# run vegeta attack | |
run() { | |
url="http://localhost:$port/upload/$2/Rovinj-Croatia.jpg" | |
echo "$1 $url" | |
echo "GET $url" | vegeta attack \ | |
-duration=10s \ | |
-rate=50 \ | vegeta report | |
echo "----" | |
sleep 1 | |
} | |
# run benchmark | |
run "Crop" "w_200,h_200,c_1" | |
run "Resize" "w_200,h_200,rz_1" | |
run "Rotate" "r_-45,w_400,h_400" | |
# remove the container and the image | |
docker rm -f "$randName" | |
docker rmi -f "$randName" |