Created
March 17, 2011 10:53
-
-
Save antirez/874153 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'socket' | |
| require 'rubygems' | |
| require 'redis' | |
| UseRawSockets = false | |
| s = TCPSocket.open("127.0.0.1",6379) | |
| s.write("MONITOR\r\n") | |
| if UseRawSockets | |
| r = TCPSocket.open("127.0.0.1",6379) | |
| q = "" | |
| [:a,:b,:c,:d,:e,:f,:g,:h,:i,:l].each{|k| | |
| q += "*2\r\n$4\r\nLLEN\r\n$1\r\n"+k.to_s+"\r\n" | |
| } | |
| r.write(q) | |
| else | |
| r = Redis.new | |
| r.pipelined { | |
| r.llen :a | |
| r.llen :b | |
| r.llen :c | |
| r.llen :d | |
| r.llen :e | |
| r.llen :f | |
| r.llen :g | |
| r.llen :h | |
| r.llen :i | |
| r.llen :l | |
| } | |
| end | |
| 2.times {s.gets} # Discard useless lines | |
| old_time = nil | |
| 8.times { | |
| line = s.gets[1..-1] | |
| time = line.split(" ")[0].to_f | |
| if old_time | |
| printf "Diff %.2f microseconds\n", (time-old_time)*1000000 | |
| end | |
| old_time = time | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment