PageRenderTime 477ms CodeModel.GetById 262ms app.highlight 4ms RepoModel.GetById 210ms app.codeStats 0ms

/tests/bench.sh

http://github.com/nicolasff/webdis
Shell | 71 lines | 56 code | 14 blank | 1 comment | 3 complexity | 04db41fd3f7f96039a1b77413d96583c MD5 | raw file
 1#!/bin/bash
 2CLIENTS=100
 3REQUESTS=100000
 4
 5HOST=$WEBDIS_HOST
 6PORT=$WEBDIS_PORT
 7
 8[ -n $HOST ] && HOST=127.0.0.1
 9[ -n $PORT ] && PORT=7379
10
11info() {
12	echo "Testing on $HOST:$PORT with $CLIENTS clients in parallel, for a total of $REQUESTS requests per benchmark."
13}
14
15once() {
16	curl -q http://$HOST:$PORT/$1 1> /dev/null 2> /dev/null
17}
18
19bench() {
20	NUM=`ab -k -c $CLIENTS -n $REQUESTS http://$HOST:$PORT/$1 2>/dev/null | grep "#/sec" | sed -e "s/[^0-9.]//g"`
21	echo -ne $NUM
22}
23
24test_ping() {
25	echo -en "PING: "
26	bench "PING"
27	echo " requests/sec."
28}
29
30test_set() {
31	echo -en "SET(hello,world): "
32	bench "SET/hello/world"
33	echo " requests/sec."
34}
35
36test_get() {
37	echo -en "GET(hello): "
38	bench "GET/hello"
39	echo " requests/sec."
40}
41
42test_incr() {
43	once "DEL/hello"
44
45	echo -en "INCR(hello): "
46	bench "INCR/hello"
47	echo " requests/sec."
48}
49
50test_lpush() {
51	once "DEL/hello"
52
53	echo -en "LPUSH(hello,abc): "
54	bench "LPUSH/hello/abc"
55	echo " requests/sec."
56}
57
58test_lrange() {
59	echo -en "LRANGE(hello,$1,$2): "
60	bench "LRANGE/hello/$1/$2"
61	echo " requests/sec."
62}
63
64info
65test_ping
66test_set
67test_get
68test_incr
69test_lpush
70test_lrange 0 10
71test_lrange 0 100