mirror of
http://github.com/valkey-io/valkey
synced 2024-11-22 18:54:58 +00:00
4d284daefd
Update references of copyright being assigned to Salvatore when it was transferred to Redis Ltd. as per https://github.com/valkey-io/valkey/issues/544. --------- Signed-off-by: Pieter Cailliau <pieter@redis.com>
28 lines
621 B
Ruby
28 lines
621 B
Ruby
# hll-err.rb - Copyright (C) 2014 Redis Ltd.
|
|
# BSD license, See the COPYING file for more information.
|
|
#
|
|
# Check error of HyperLogLog implementation for different set sizes.
|
|
|
|
require 'rubygems'
|
|
require 'redis'
|
|
require 'digest/sha1'
|
|
|
|
r = Redis.new
|
|
r.del('hll')
|
|
i = 0
|
|
while true do
|
|
100.times {
|
|
elements = []
|
|
1000.times {
|
|
ele = Digest::SHA1.hexdigest(i.to_s)
|
|
elements << ele
|
|
i += 1
|
|
}
|
|
r.pfadd('hll',elements)
|
|
}
|
|
approx = r.pfcount('hll')
|
|
abs_err = (approx-i).abs
|
|
rel_err = 100.to_f*abs_err/i
|
|
puts "#{i} vs #{approx}: #{rel_err}%"
|
|
end
|