remove benchmark.sh, improve bulk.sh

This commit is contained in:
jomo 2015-03-14 06:37:16 +01:00
parent dfaa79b9c7
commit 4c7da4940e
2 changed files with 32 additions and 32 deletions

View File

@ -1,18 +0,0 @@
#!/usr/bin/env bash
host="$1"
if [ -z "$host" ]; then
echo "Usage: $0 <host uri> > benchmark.txt 2>&1"
exit 1
fi
# insert newline after uuids
id_file="$(echo | cat 'uuids.txt' - 'usernames.txt')"
mapfile ids <<< $id_file
bench() {
for id in $ids; do
curl -sSL -o /dev/null -w "%{url_effective} %{http_code} %{time_total}s\\n" "$host/avatars/$id?helm"
done
}
time bench

View File

@ -1,17 +1,35 @@
#!/bin/bash #!/usr/bin/env bash
async="true"
interval="0.1"
if [ "$1" = "-s" ]; then
async=""
shift
elif [ "$1" = "-i" ]; then
interval="$2"
shift 2
fi
host="$1" host="$1"
if [ -z "$host" ]; then shift
echo "Usage: $0 <host>" if [ -z "$host" ] || [ ! -z "$@" ]; then
echo "Usage: $0 [-s | -i <interval>] <host uri>"
exit 1 exit 1
fi fi
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
rm -f "$dir/../skins/"*.png || exit 1 # insert newline after uuids
for uuid in `cat "$dir/uuids.txt"`; do id_file="$(echo | cat 'uuids.txt' - 'usernames.txt')"
uuid=`echo "$uuid" | tr -d "\r"` mapfile ids <<< $id_file
size=$(( ((RANDOM<<15)|RANDOM) % 514 - 1 )) # random number from -1 to 513
helm="" bulk() {
if [ "$(( ((RANDOM<<15)|RANDOM) % 2 ))" -eq "1" ]; then trap return INT
helm="&helm" for id in $ids; do
if [ -z "$async" ]; then
curl -sSL -o /dev/null -w "%{url_effective} %{http_code} %{time_total}s\\n" -- "$host/avatars/$id?helm"
else
curl -sSL -o /dev/null -w "%{url_effective} %{http_code} %{time_total}s\\n" -- "$host/avatars/$id?helm" &
sleep "$interval"
fi fi
curl -sSL -o /dev/null -w "%{url_effective} %{http_code} %{time_total}s\\n" "http://$host/avatars/$uuid?size=$size$helm"
done done
}
time bulk