mirror of
https://github.com/fluencelabs/redis
synced 2025-03-30 22:31:03 +00:00
hll-err.rb: speedup using pipelining.
This commit is contained in:
parent
f29123364b
commit
fdf81b2d35
@ -9,13 +9,19 @@ require 'digest/sha1'
|
|||||||
|
|
||||||
r = Redis.new
|
r = Redis.new
|
||||||
r.del('hll')
|
r.del('hll')
|
||||||
(1..1000000000).each{|i|
|
i = 0
|
||||||
ele = Digest::SHA1.hexdigest(i.to_s)
|
while true do
|
||||||
r.hlladd('hll',ele)
|
100.times {
|
||||||
if i != 0 && (i%10000) == 0
|
elements = []
|
||||||
approx = r.hllcount('hll')
|
1000.times {
|
||||||
abs_err = (approx-i).abs
|
ele = Digest::SHA1.hexdigest(i.to_s)
|
||||||
rel_err = 100.to_f*abs_err/i
|
elements << ele
|
||||||
puts "#{i} vs #{approx}: #{rel_err}%"
|
i += 1
|
||||||
end
|
}
|
||||||
}
|
r.hlladd('hll',*elements)
|
||||||
|
}
|
||||||
|
approx = r.hllcount('hll')
|
||||||
|
abs_err = (approx-i).abs
|
||||||
|
rel_err = 100.to_f*abs_err/i
|
||||||
|
puts "#{i} vs #{approx}: #{rel_err}%"
|
||||||
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user