From 4c7da4940ee2237758a7aaf18c9438f1058d2529 Mon Sep 17 00:00:00 2001 From: jomo Date: Sat, 14 Mar 2015 06:37:16 +0100 Subject: [PATCH] remove benchmark.sh, improve bulk.sh --- test/benchmark.sh | 18 ------------------ test/bulk.sh | 46 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 32 deletions(-) delete mode 100755 test/benchmark.sh diff --git a/test/benchmark.sh b/test/benchmark.sh deleted file mode 100755 index 9a91b25..0000000 --- a/test/benchmark.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -host="$1" -if [ -z "$host" ]; then - echo "Usage: $0 > 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 \ No newline at end of file diff --git a/test/bulk.sh b/test/bulk.sh index bbbac09..710d404 100755 --- a/test/bulk.sh +++ b/test/bulk.sh @@ -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" -if [ -z "$host" ]; then - echo "Usage: $0 " +shift +if [ -z "$host" ] || [ ! -z "$@" ]; then + echo "Usage: $0 [-s | -i ] " exit 1 fi -dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -rm -f "$dir/../skins/"*.png || exit 1 -for uuid in `cat "$dir/uuids.txt"`; do - uuid=`echo "$uuid" | tr -d "\r"` - size=$(( ((RANDOM<<15)|RANDOM) % 514 - 1 )) # random number from -1 to 513 - helm="" - if [ "$(( ((RANDOM<<15)|RANDOM) % 2 ))" -eq "1" ]; then - helm="&helm" - fi - curl -sSL -o /dev/null -w "%{url_effective} %{http_code} %{time_total}s\\n" "http://$host/avatars/$uuid?size=$size$helm" -done \ No newline at end of file + +# insert newline after uuids +id_file="$(echo | cat 'uuids.txt' - 'usernames.txt')" +mapfile ids <<< $id_file + +bulk() { + trap return INT + 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 + done +} + +time bulk \ No newline at end of file