Created
March 6, 2013 23:12
-
-
Save sfaxon/5104129 to your computer and use it in GitHub Desktop.
benchmark redis sorted set using zadd
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
r = Redis.connect(:url => 'redis://localhost:6379/2', :thread_safe => true) | |
k = 'livecount' | |
Benchmark.bm do |x| | |
x.report do | |
r.zrange(k,0,-1).count | |
end | |
x.report do | |
r.zremrangebyscore(k, 0, Time.now.to_i) | |
end | |
x.report do | |
(0..10000).each do |v| | |
r.zadd(k, Time.now.to_i + 60, "#{v}") # keep for 1 min | |
end | |
end | |
end | |
r.zremrangebyscore(k, 0, Time.now.to_i) | |
r.zrange(k,0,-1).count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment