bloomfilter-rb 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/benchmark/redis-bm.rb +34 -0
- data/lib/bloomfilter/redis.rb +6 -1
- data/lib/bloomfilter/version.rb +1 -1
- metadata +3 -2
@@ -0,0 +1,34 @@
|
|
1
|
+
$:<< 'lib'
|
2
|
+
|
3
|
+
require 'benchmark'
|
4
|
+
require 'bloomfilter-rb'
|
5
|
+
|
6
|
+
n = 10000
|
7
|
+
|
8
|
+
Benchmark.bm do |x|
|
9
|
+
r = BloomFilter::Redis.new
|
10
|
+
|
11
|
+
x.report("insert") do
|
12
|
+
n.times do
|
13
|
+
r.insert("a")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
x.report("lookup present") do
|
18
|
+
n.times do
|
19
|
+
r.include?("a")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
x.report("lookup missing") do
|
24
|
+
n.times do
|
25
|
+
r.include?("b")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
# user system total real
|
32
|
+
# insert 1.000000 0.380000 1.380000 ( 1.942181)
|
33
|
+
# lookup present 1.030000 0.470000 1.500000 ( 2.577577)
|
34
|
+
# lookup missing 0.370000 0.160000 0.530000 ( 1.060429)
|
data/lib/bloomfilter/redis.rb
CHANGED
@@ -26,8 +26,13 @@ module BloomFilter
|
|
26
26
|
|
27
27
|
def include?(*keys)
|
28
28
|
keys.each do |key|
|
29
|
+
indexes = []
|
30
|
+
indexes_for(key) { |idx| indexes << idx }
|
31
|
+
|
32
|
+
return false if @db.getbit(@opts[:namespace], indexes.shift) == 0
|
33
|
+
|
29
34
|
result = @db.pipelined do
|
30
|
-
|
35
|
+
indexes.each do |idx|
|
31
36
|
@db.getbit(@opts[:namespace], idx)
|
32
37
|
end
|
33
38
|
end
|
data/lib/bloomfilter/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: bloomfilter-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 2.1.
|
5
|
+
version: 2.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ilya Grigorik
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-03-
|
14
|
+
date: 2011-03-31 00:00:00 -04:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- Gemfile.lock
|
64
64
|
- README.md
|
65
65
|
- Rakefile
|
66
|
+
- benchmark/redis-bm.rb
|
66
67
|
- bloomfilter-rb.gemspec
|
67
68
|
- examples/counting-redis.rb
|
68
69
|
- examples/pure-ruby-bf.rb
|