diff options
author | antirez <antirez@gmail.com> | 2014-03-28 18:35:14 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-03-28 18:35:21 +0100 |
commit | f29123364b9f953c2467e52d8bf91c7cfd9a7f5d (patch) | |
tree | ed802fdbab3e66e8ad014c9de6bdaa47131c024c /utils | |
parent | f90a4af3d75a3a97c6572429ad7bdb9a207c8bce (diff) | |
download | redis-f29123364b9f953c2467e52d8bf91c7cfd9a7f5d.tar.gz |
hll-err.rb added to test error rate of Redis HyperLogLog.
Diffstat (limited to 'utils')
-rw-r--r-- | utils/hyperloglog/hll-err.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/utils/hyperloglog/hll-err.rb b/utils/hyperloglog/hll-err.rb new file mode 100644 index 000000000..96f9a68ec --- /dev/null +++ b/utils/hyperloglog/hll-err.rb @@ -0,0 +1,21 @@ +# 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') +(1..1000000000).each{|i| + ele = Digest::SHA1.hexdigest(i.to_s) + r.hlladd('hll',ele) + if i != 0 && (i%10000) == 0 + approx = r.hllcount('hll') + abs_err = (approx-i).abs + rel_err = 100.to_f*abs_err/i + puts "#{i} vs #{approx}: #{rel_err}%" + end +} |