X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/9f080a01fac2353a1c3a855729cd337ef4384c5a..af0b220756571bc8faf57a0c7b7389dd86a60376:/utils/speed-regression.tcl diff --git a/utils/speed-regression.tcl b/utils/speed-regression.tcl index 503a0799..86a7d8d8 100755 --- a/utils/speed-regression.tcl +++ b/utils/speed-regression.tcl @@ -2,6 +2,12 @@ # Copyright (C) 2011 Salvatore Sanfilippo # Released under the BSD license like Redis itself +source ../tests/support/redis.tcl +set ::port 12123 +set ::tests {PING,SET,GET,INCR,LPUSH,LPOP,SADD,SPOP,LRANGE_100,LRANGE_600,MSET} +set ::datasize 16 +set ::requests 100000 + proc run-tests branches { set runs {} set branch_id 0 @@ -22,16 +28,21 @@ proc run-tests branches { # Start the Redis server puts " starting the server... [exec ./redis-server -v]" - set pids [exec echo "port 12123\nloglevel warning\n" | ./redis-server - > /dev/null 2> /dev/null &] + set pids [exec echo "port $::port\nloglevel warning\n" | ./redis-server - > /dev/null 2> /dev/null &] + puts " pids: $pids" after 1000 puts " running the benchmark" - set output [exec /tmp/redis-benchmark -n 100000 --csv -p 12123] + + set r [redis 127.0.0.1 $::port] + set i [$r info] + puts " redis INFO shows version: [lindex [split $i] 0]" + $r close + + set output [exec /tmp/redis-benchmark -n $::requests -t $::tests -d $::datasize --csv -p $::port] lappend runs $b $output puts " killing server..." - catch { - exec kill -9 [lindex $pids 0] - exec kill -9 [lindex $pids 1] - } + catch {exec kill -9 [lindex $pids 0]} + catch {exec kill -9 [lindex $pids 1]} incr branch_id } return $runs @@ -49,13 +60,18 @@ proc get-result-with-name {output name} { return "n/a" } -proc combine-results {results} { - set tests { - ping set get incr lpush lpop sadd spop - "lrange (first 100 elements)" - "lrange (first 600 elements)" - "mset (10 keys)" +proc get-test-names output { + set names {} + foreach line [split $output "\n"] { + lassign [split $line ","] key value + set key [string tolower [string range $key 1 end-1]] + lappend names $key } + return $names +} + +proc combine-results {results} { + set tests [get-test-names [lindex $results 1]] foreach test $tests { puts $test foreach {branch output} $results { @@ -73,6 +89,8 @@ proc main {} { slowset 2.2.0 2.4.0 unstable slowset } set results [run-tests $branches] + puts "\n" + puts "# Test results: datasize=$::datasize requests=$::requests" puts [combine-results $results] } @@ -82,4 +100,31 @@ if {![file exists speed-regression.tcl]} { puts "Example: cd utils; ./speed-regression.tcl" exit 1 } + +# Make sure there is not already a server runnign on port 12123 +set is_not_running [catch {set r [redis 127.0.0.1 $::port]}] +if {!$is_not_running} { + puts "Sorry, you have a running server on port $::port" + exit 1 +} + +# parse arguments +for {set j 0} {$j < [llength $argv]} {incr j} { + set opt [lindex $argv $j] + set arg [lindex $argv [expr $j+1]] + if {$opt eq {--tests}} { + set ::tests $arg + incr j + } elseif {$opt eq {--datasize}} { + set ::datasize $arg + incr j + } elseif {$opt eq {--requests}} { + set ::requests $arg + incr j + } else { + puts "Wrong argument: $opt" + exit 1 + } +} + main