-
Notifications
You must be signed in to change notification settings - Fork 0
/
bench.sh
executable file
·154 lines (117 loc) · 3.38 KB
/
bench.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash
# Remember to close binlog output
config="./etc/ledis.conf"
benchmark="benchmark.md"
leveldb="leveldb"
goleveldb="goleveldb"
rocksdb="rocksdb"
lmdb="lmdb"
boltdb="boltdb"
hyperleveldb="hyperleveldb"
redis="redis"
ssdb="ssdb"
ledis="ledis"
ledis_server="ledis-server"
home=$(pwd)
# Set up your environment here
ledis_path="/Users/holys/work/src/github.com/siddontang/ledisdb"
ssdb_path="/Users/holys/work/ssdb-master"
redis_path="/Users/holys/work/redis-2.8.13"
function kill_process()
{
pid=$(ps axu|grep -v grep |grep $1 | awk '{print $2}')
kill $pid > /dev/null 2&>1
}
function ledis_bench()
{
cd "$ledis_path"
source ./dev.sh
rm -rf ./var
nohup ledis-server -config=$config -db_name=$1 >nohup.out 2&>1 &
pid=$(ps axu|grep -v grep |grep ledis-server | awk '{print $2}')
if [ "$4" == "$redis" ];then
echo "\n\`\`\`$1_$redis"
redis-benchmark -p $2 -n $3 -t set,incr,get,lpush,lpop,lrange,mset -q
echo "\`\`\`"
elif [ "$4" == "$ledis" ];then
echo "\n\`\`\`$1_$ledis"
ledis-benchmark -port=$2 -n=$3
echo "\`\`\`"
fi
kill_process $ledis_server
cd $home
sleep 1
}
function redis_bench()
{
cd "$redis_path"
nohup ./src/redis-server redis.conf &
#FIXME: weird! If remove the following line, benchmark not work correctly.
pid=$(ps axu|grep -v grep |grep redis-server | awk '{print $2}')
if [ "$3" == "$redis" ]; then
echo "\n\`\`\`redis_redis"
redis-benchmark -p $1 -n $2 -t set,incr,get,lpush,lpop,lrange,mset -q
echo "\`\`\`"
elif [ "$3" == "$ledis" ];then
echo "\n\`\`\`redis_ledis"
ledis-benchmark -port=$1 -n=$2
echo "\`\`\`"
fi
kill_process redis-server
cd $home
sleep 1
}
function ssdb_bench()
{
cd $ssdb_path
rm -rf ./var
mkdir -p ./var
nohup ./ssdb-server ssdb.conf &
#FIXME: weird! If remove the following line, benchmark not work correctly.
pid=$(ps axu|grep -v grep |grep ssdb-server | awk '{print $2}')
if [ "$3" == "$redis" ]; then
echo "\n\`\`\`ssdb_redis"
redis-benchmark -p $1 -n $2 -t set,incr,get,lpush,lpop,lrange,mset -q
echo "\`\`\`"
elif [ "$3" == "$ledis" ];then
echo "\n\`\`\`ssdb_ledis"
ledis-benchmark -port=$1 -n=$2
echo "\`\`\`"
fi
kill_process ssdb-server
cd $home
sleep 1
}
function bench_all()
{
ledis_bench $goleveldb 6380 $1 $redis
ledis_bench $leveldb 6380 $1 $redis
ledis_bench $rocksdb 6380 $1 $redis
ledis_bench $lmdb 6380 $1 $redis
ledis_bench $boltdb 6380 $1 $redis
redis_bench 6379 $1 $redis
ssdb_bench 8888 $1 $redis
ledis_bench $goleveldb 6380 $2 $ledis
ledis_bench $leveldb 6380 $2 $ledis
ledis_bench $rocksdb 6380 $2 $ledis
ledis_bench $lmdb 6380 $2 $ledis
ledis_bench $boltdb 6380 $2 $ledis
redis_bench 6379 $2 $ledis
ssdb_bench 8888 $2 $ledis
ledis_bench $hyperleveldb 6380 $1 $redis
ledis_bench $hyperleveldb 6380 $1 $ledis
}
function main()
{
if [ -f "$benchmark" ];then
rm $benchmark
fi
#change your benchmark max requests number here
# bench_all $1 $2
# $1 for redis-benchmark tool
# $2 for ledis-benchmark tool, greater than 1000 is must
bench_all 50000 3000
}
main
#FIXME: have to copy & paste the output to `benchmark.md` file.
# output redirect not work for me :(