1
0
mirror of https://github.com/fluencelabs/redis synced 2025-07-26 14:01:56 +00:00
Files
deps
src
tests
utils
create-cluster
graphs
hashtable
hyperloglog
.gitignore
hll-err.rb
hll-gnuplot-graph.rb
lru
releasetools
build-static-symbols.tcl
cluster_fail_time.tcl
corrupt_rdb.c
generate-command-help.rb
install_server.sh
redis-copy.rb
redis-sha1.rb
redis_init_script
redis_init_script.tpl
speed-regression.tcl
whatisdoing.sh
.gitignore
00-RELEASENOTES
BUGS
CONTRIBUTING
COPYING
INSTALL
MANIFESTO
Makefile
README.md
redis.conf
runtest
runtest-cluster
runtest-sentinel
sentinel.conf
redis/utils/hyperloglog/hll-err.rb

28 lines
638 B
Ruby
Raw Normal View History

# hll-err.rb - Copyright (C) 2014 Salvatore Sanfilippo
# BSD license, See the COPYING file for more information.
#
# Check error of HyperLogLog Redis implementation for different set sizes.
require 'rubygems'
require 'redis'
require 'digest/sha1'
r = Redis.new
r.del('hll')
2014-03-28 22:25:26 +01:00
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)
2014-03-28 22:25:26 +01:00
}
approx = r.pfcount('hll')
2014-03-28 22:25:26 +01:00
abs_err = (approx-i).abs
rel_err = 100.to_f*abs_err/i
puts "#{i} vs #{approx}: #{rel_err}%"
end