Last active
December 16, 2015 10:29
-
-
Save azat/5420927 to your computer and use it in GitHub Desktop.
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 | |
# | |
# Original is here https://raw.github.com/azat/boostcache/master/benchmarks/one_connection.sh | |
# | |
set -e | |
if ! $( pidof boostcached &> /dev/null ); then | |
echo "First start boostcached" | |
# exit 1 | |
fi | |
#PORT=9876 | |
#HOST=localhost | |
LIMIT=1000000 | |
TMP_FILE="/tmp/test-boostcached-commands-$RANDOM.txt" | |
trap 'echo Removing temporary data; rm -f $TMP_FILE' EXIT | |
function run_test_client() | |
{ | |
echo "Sending data" | |
START=$(date +%s) | |
COUNT=$(gawk 'BEGIN { | |
serverConnection = "/inet4/tcp/0/localhost/9876" | |
count=0 | |
} | |
{ | |
# write to server | |
print $0 |& serverConnection | |
++count | |
# read from server | |
serverConnection |& getline | |
# We do not need to print output test data | |
# print $0 | |
} | |
END { | |
close(service) | |
print count | |
}' $1) | |
END=$(date +%s) | |
ESTIMATE=$((END - START)) | |
# Queries per second | |
QPS=$((COUNT / ESTIMATE)) | |
echo "Estimate $ESTIMATE sec ($QPS qps)" | |
} | |
echo "Preparing data for HSET ..." | |
for ((i=1; i<=$LIMIT; i++)); do | |
echo "HSET ${i}_key ${i}_value" >> $TMP_FILE | |
done | |
run_test_client $TMP_FILE | |
rm $TMP_FILE | |
echo "Preparing data for HGET ..." | |
for ((i=1; i<=$LIMIT; i++)); do | |
echo "HGET ${i}_key" >> $TMP_FILE | |
done | |
run_test_client $TMP_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment