Skip to content

Commit

Permalink
removed all but FFI FNV, bumped version to 1.2.0, updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
colinsurprenant committed Feb 27, 2013
1 parent 0b699cb commit 0a56e9b
Show file tree
Hide file tree
Showing 15 changed files with 11 additions and 449 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ Gemfile.lock
pkg/*
.ruby-version
tmp/
vendor/
vendor/
.vagrant
Vagrantfile
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# 1.0.0, 05-09-2012
- initial release

# 1.1.0 - 1.1.2
# 1.1.x
- bad gems, yanked from Rubygems

# 1.1.3, 02-27-2013
# 1.2.0, 02-27-2013
- refactored to use ffi-compiler
- only compile c-ext on non-JRuby platforms
- now only using FFI FNV hashing, removed all other implementations
- test on JRuby 1.7.3 and MRI Ruby 2.0.0
- FFI performance improvements
39 changes: 2 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Bloombroom v1.1.3
# Bloombroom v1.2.0

[![build status](https://secure.travis-ci.org/colinsurprenant/bloombroom.png)](http://travis-ci.org/colinsurprenant/bloombroom)

- Standard **Bloomfilter** class for bounded key space
- **ContinuousBloomfilter** class for unbounded keys (**stream**)
- Bitfield class (single bit field)
- BitBucketField class (multiple bit fields)
- pure, C-ext & FFI extensions FNV hash classes
- Fast FNV hashing using C implementation with FFI bindings.

The Bloom filter is a space-efficient probabilistic data structure that is used to test whether an element is a member of a set. False positives are possible, but false negatives are not. See [wikipedia](http://en.wikipedia.org/wiki/Bloom_filter).

Expand Down Expand Up @@ -174,41 +174,7 @@ BloomFilter 120000 adds + 120000 tests in 1.64s, 146008 ops/s
## Benchmarks
All benchmarks have been run on a MacbookPro with a 2.66GHz i7 with 8GB RAM on OSX 10.6.8 with MRI Ruby 1.9.3p194

### Hashing
The Hashing benchmark compares the performance of SHA1, MD5, two native Ruby FNV (A & B) implementations, a C implementation as a C extension and FFI extension for 32 and 64 bits hashes.

``` sh
ruby benchmark/fnv.rb
```

```
benchmarking for 1000000 iterations
user system total real
MD5: 1.900000 0.010000 1.910000 ( 1.912995)
SHA-1: 2.110000 0.000000 2.110000 ( 2.109739)
native FNV A 32: 32.470000 0.110000 32.580000 ( 32.596759)
native FNV A 64: 38.330000 0.570000 38.900000 ( 38.923384)
native FNV B 32: 4.870000 0.020000 4.890000 ( 4.882862)
native FNV B 64: 37.700000 0.110000 37.810000 ( 37.842873)
ffi FNV 32: 0.760000 0.010000 0.770000 ( 0.754941)
ffi FNV 64: 0.890000 0.000000 0.890000 ( 0.901954)
c-ext FNV 32: 0.310000 0.000000 0.310000 ( 0.307131)
c-ext FNV 64: 0.480000 0.000000 0.480000 ( 0.485310)
MD5: 522740 ops/s
SHA-1: 473992 ops/s
native FNV A 32: 30678 ops/s
native FNV A 64: 25691 ops/s
native FNV B 32: 204798 ops/s
native FNV B 64: 26425 ops/s
ffi FNV 32: 1324607 ops/s
ffi FNV 64: 1108704 ops/s
c-ext FNV 32: 3255939 ops/s
c-ext FNV 64: 2060538 ops/s
```

### Bloomfilter
The Bloomfilter class is using the FFI FNV hashing by default, for speed and compatibility.

``` sh
ruby benchmark/bloom_filter.rb
Expand All @@ -233,7 +199,6 @@ BloomFilter m=2875518, k=13 include? 119154 ops/s
```

### ContinuousBloomfilter
The ContinuousBloomfilter class is using the FFI FNV hashing by default, for speed and compatibility.

``` sh
ruby benchmark/continuous_bloom_filter.rb
Expand Down
13 changes: 1 addition & 12 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,18 @@ require 'rspec/core/rake_task'
require 'ffi'
require 'ffi-compiler/compile_task'

task :default => [:clean, :compile_ffi] + ((RUBY_PLATFORM =~ /java/) ? [] : [:compile_cext]) + [:spec]
task :default => [:clean, :compile_ffi, :spec]

desc "clean, make and run specs"
task :spec do
RSpec::Core::RakeTask.new
end

desc "C ext compiler"
task :compile_cext do
Dir.chdir("ext/bloombroom/hash/") do
ruby "extconf.rb"
sh "make install"
end
cp "ext/bloombroom/hash/" + (FFI::Platform.mac? ? "cext_fnv.bundle" : "cext_fnv." + FFI::Platform::LIBSUFFIX), "lib/bloombroom/hash"
end

desc "FFI compiler"
namespace "ffi-compiler" do
FFI::Compiler::CompileTask.new('ffi/bloombroom/hash/ffi_fnv')
end
task :compile_ffi => ["ffi-compiler:default"]

CLEAN.include('ext/**/*{.o,.log,.so,.bundle}')
CLEAN.include('ffi/**/*{.o,.log,.so,.bundle}')
CLEAN.include('lib/**/*{.o,.log,.so,.bundle}')
CLEAN.include('ext/**/Makefile')
43 changes: 0 additions & 43 deletions benchmark/fnv.rb

This file was deleted.

6 changes: 1 addition & 5 deletions bloombroom.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ Gem::Specification.new do |s|
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
s.test_files = s.files.grep(%r{^(test|spec|features)/})
s.require_paths = ["lib"]
if ::RUBY_PLATFORM =~ /java/
s.extensions = ["ffi/bloombroom/hash/Rakefile"]
else
s.extensions = ["ext/bloombroom/hash/extconf.rb", "ffi/bloombroom/hash/Rakefile"]
end
s.extensions = ["ext/bloombroom/hash/extconf.rb", "ffi/bloombroom/hash/Rakefile"]

s.has_rdoc = false
s.license = 'Apache 2.0'
Expand Down
91 changes: 0 additions & 91 deletions ext/bloombroom/hash/cext_fnv.c

This file was deleted.

3 changes: 0 additions & 3 deletions ext/bloombroom/hash/extconf.rb

This file was deleted.

3 changes: 0 additions & 3 deletions lib/bloombroom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@ class FNVFFI
require "bloombroom/filter/bloom_helper"
require "bloombroom/filter/bloom_filter"
require "bloombroom/filter/continuous_bloom_filter"
require "bloombroom/hash/fnv_a"
require "bloombroom/hash/fnv_b"
require "bloombroom/hash/ffi_fnv"
require "bloombroom/hash/cext_fnv" unless RUBY_PLATFORM =~ /java/
100 changes: 0 additions & 100 deletions lib/bloombroom/hash/fnv_a.rb

This file was deleted.

Loading

0 comments on commit 0a56e9b

Please sign in to comment.