-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_redis.sh
More file actions
executable file
·106 lines (93 loc) · 1.69 KB
/
test_redis.sh
File metadata and controls
executable file
·106 lines (93 loc) · 1.69 KB
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
#!/bin/bash
total=128
num=20000000
threadnum=32
datasize=16
redis_start() {
count=0
while [ $count -lt $total ]
do
count=`expr $count + 1`
port=`expr $count + 6379`
echo $port
redis-server --port $port > /dev/null 2>&1 &
done
}
redis_set() {
count=0
while [ $count -lt $total ]
do
count=`expr $count + 1`
port=`expr $count + 6379`
echo $port
log="log/set_${datasize}_${port}.log"
current_time=`date '+%Y-%m-%d %H:%M:%S'`
echo $current_time > $log
nohup redis-benchmark -p $port -t set -n $num -c $threadnum -d $datasize -r $num -P 8 -k 1 >> $log 2>&1 &
done
}
redis_get() {
count=0
while [ $count -lt $total ]
do
count=`expr $count + 1`
port=`expr $count + 6379`
echo $port
log="log/get_${datasize}_${port}.log"
current_time=`date '+%Y-%m-%d %H:%M:%S'`
echo $current_time > $log
nohup redis-benchmark -p $port -t get -n $num -c $threadnum -d $datasize -r $num -P 8 -k 1 >> $log 2>&1 &
done
}
redis_stop() {
ps aux | grep 'redis-server' | grep -v 6379 | awk '{print $2}' | xargs -i kill {}
}
set_test() {
redis_stop
sleep 5
redis_start
sleep 2
redis_set
}
get_test() {
redis_get
}
test() {
set_test
sleep 1
while [ 1 ]
do
bench_num=`ps aux | grep redis-benchmark | wc -l`
if [ $bench_num -eq 1 ]; then
break
fi
sleep 2
echo "wait set"
done
sleep 10
get_test
sleep 1
while [ 1 ]
do
bench_num=`ps aux | grep redis-benchmark | wc -l`
if [ $bench_num -eq 1 ]; then
break
fi
sleep 2
echo "wait get"
done
sleep 10
}
mkdir -p log
datasize=16
test
datasize=32
test
datasize=64
test
datasize=128
num=4000000
test
datasize=256
num=4000000
test