summaryrefslogtreecommitdiff
path: root/utils/speed-regression.tcl
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2011-11-04 20:45:46 +0100
committerantirez <antirez@gmail.com>2011-11-04 20:45:46 +0100
commit9f080a01fac2353a1c3a855729cd337ef4384c5a (patch)
treee1c0ba245b560c25e25989c36d9c4175ef7ef16e /utils/speed-regression.tcl
parent7b86f5e6d5ecdafc3e47f640ac99614ee2295c06 (diff)
downloadredis-9f080a01fac2353a1c3a855729cd337ef4384c5a.tar.gz
first version of the speed regression test
Diffstat (limited to 'utils/speed-regression.tcl')
-rwxr-xr-xutils/speed-regression.tcl85
1 files changed, 85 insertions, 0 deletions
diff --git a/utils/speed-regression.tcl b/utils/speed-regression.tcl
new file mode 100755
index 000000000..503a0799e
--- /dev/null
+++ b/utils/speed-regression.tcl
@@ -0,0 +1,85 @@
+#!/usr/bin/env tclsh8.5
+# Copyright (C) 2011 Salvatore Sanfilippo
+# Released under the BSD license like Redis itself
+
+proc run-tests branches {
+ set runs {}
+ set branch_id 0
+ foreach b $branches {
+ cd ../src
+ puts "Benchmarking $b"
+ exec -ignorestderr git checkout $b 2> /dev/null
+ exec -ignorestderr make clean 2> /dev/null
+ puts " compiling..."
+ exec -ignorestderr make 2> /dev/null
+
+ if {$branch_id == 0} {
+ puts " copy redis-benchmark from unstable to /tmp..."
+ exec -ignorestderr cp ./redis-benchmark /tmp
+ incr branch_id
+ continue
+ }
+
+ # 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 &]
+ after 1000
+ puts " running the benchmark"
+ set output [exec /tmp/redis-benchmark -n 100000 --csv -p 12123]
+ lappend runs $b $output
+ puts " killing server..."
+ catch {
+ exec kill -9 [lindex $pids 0]
+ exec kill -9 [lindex $pids 1]
+ }
+ incr branch_id
+ }
+ return $runs
+}
+
+proc get-result-with-name {output name} {
+ foreach line [split $output "\n"] {
+ lassign [split $line ","] key value
+ set key [string tolower [string range $key 1 end-1]]
+ set value [string range $value 1 end-1]
+ if {$key eq [string tolower $name]} {
+ return $value
+ }
+ }
+ 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)"
+ }
+ foreach test $tests {
+ puts $test
+ foreach {branch output} $results {
+ puts [format "%-20s %s" \
+ $branch [get-result-with-name $output $test]]
+ }
+ puts {}
+ }
+}
+
+proc main {} {
+ # Note: the first branch is only used in order to get the redis-benchmark
+ # executable. Tests are performed starting from the second branch.
+ set branches {
+ slowset 2.2.0 2.4.0 unstable slowset
+ }
+ set results [run-tests $branches]
+ puts [combine-results $results]
+}
+
+# Force the user to run the script from the 'utils' directory.
+if {![file exists speed-regression.tcl]} {
+ puts "Please make sure to run speed-regression.tcl while inside /utils."
+ puts "Example: cd utils; ./speed-regression.tcl"
+ exit 1
+}
+main