1 #!/usr/bin/env tclsh8.5
2 # Copyright (C) 2011 Salvatore Sanfilippo
3 # Released under the BSD license like Redis itself
5 source ..
/tests
/support
/redis.tcl
7 set ::tests {PING
,SET
,GET
,INCR
,LPUSH
,LPOP
,SADD
,SPOP
,LRANGE_100
,LRANGE_600
,MSET
}
11 proc run-tests branches
{
16 puts "Benchmarking $b"
17 exec -ignorestderr git checkout
$b 2> /dev
/null
18 exec -ignorestderr make clean
2> /dev
/null
20 exec -ignorestderr make
2> /dev
/null
22 if {$branch_id == 0} {
23 puts " copy redis-benchmark from unstable to /tmp..."
24 exec -ignorestderr cp .
/redis-benchmark
/tmp
29 # Start the Redis server
30 puts " starting the server... [exec ./redis-server -v]"
31 set pids
[exec echo
"port $::port\nloglevel warning\n" | .
/redis-server
- > /dev
/null
2> /dev
/null
&]
34 puts " running the benchmark"
36 set r
[redis
127.0.0.1 $::port]
38 puts " redis INFO shows version: [lindex [split $i] 0]"
41 set output
[exec /tmp
/redis-benchmark
-n $::requests -t $::tests -d $::datasize --csv -p $::port]
42 lappend runs
$b $output
43 puts " killing server..."
44 catch {exec kill
-9 [lindex $pids 0]}
45 catch {exec kill
-9 [lindex $pids 1]}
51 proc get-result-with-name
{output name
} {
52 foreach line
[split $output "\n"] {
53 lassign
[split $line ","] key value
54 set key
[string tolower
[string range
$key 1 end-1
]]
55 set value
[string range
$value 1 end-1
]
56 if {$key eq
[string tolower
$name]} {
63 proc get-test-names output
{
65 foreach line
[split $output "\n"] {
66 lassign
[split $line ","] key value
67 set key
[string tolower
[string range
$key 1 end-1
]]
73 proc combine-results
{results
} {
74 set tests
[get-test-names
[lindex $results 1]]
77 foreach {branch output
} $results {
78 puts [format "%-20s %s" \
79 $branch [get-result-with-name
$output $test]]
86 # Note: the first branch is only used in order to get the redis-benchmark
87 # executable. Tests are performed starting from the second branch.
89 slowset
2.2.0 2.4.0 unstable slowset
91 set results
[run-tests
$branches]
93 puts "# Test results: datasize=$::datasize requests=$::requests"
94 puts [combine-results
$results]
97 # Force the user to run the script from the 'utils' directory.
98 if {![file exists speed-regression.tcl
]} {
99 puts "Please make sure to run speed-regression.tcl while inside /utils."
100 puts "Example: cd utils; ./speed-regression.tcl"
104 # Make sure there is not already a server runnign on port 12123
105 set is_not_running
[catch {set r
[redis
127.0.0.1 $::port]}]
106 if {!$is_not_running} {
107 puts "Sorry, you have a running server on port $::port"
112 for {set j
0} {$j < [llength $argv]} {incr j
} {
113 set opt
[lindex $argv $j]
114 set arg
[lindex $argv [expr $j+1]]
115 if {$opt eq
{--tests}} {
118 } elseif
{$opt eq
{--datasize}} {
121 } elseif
{$opt eq
{--requests}} {
125 puts "Wrong argument: $opt"