Skip to content

Commit

Permalink
update benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
tonytonyjan committed Dec 26, 2015
1 parent 093bd09 commit ce27575
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,31 +106,33 @@ str_1 | str_2 | origin | jaro_winkler | fuzzystringmatch | hotwater |

```
$ bundle exec rake benchmark
2015-12-12 20:37:34 UTC
2015-12-26 20:35:47 UTC
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
# C Extension
Rehearsal ----------------------------------------------------------
jaro_winkler 1.4.0 0.340000 0.000000 0.340000 ( 0.345071)
fuzzystringmatch 0.9.7 0.470000 0.000000 0.470000 ( 0.467571)
hotwater 0.1.2 0.380000 0.000000 0.380000 ( 0.382495)
amatch 0.3.0 1.020000 0.010000 1.030000 ( 1.032459)
------------------------------------------------- total: 2.220000sec
jaro_winkler 1.4.0 0.340000 0.000000 0.340000 ( 0.343759)
fuzzystringmatch 0.9.7 0.420000 0.000000 0.420000 ( 0.434254)
hotwater 0.1.2 0.300000 0.000000 0.300000 ( 0.297175)
amatch 0.3.0 0.960000 0.010000 0.970000 ( 0.974599)
------------------------------------------------- total: 2.030000sec
user system total real
jaro_winkler 1.4.0 0.350000 0.000000 0.350000 ( 0.354300)
fuzzystringmatch 0.9.7 0.480000 0.000000 0.480000 ( 0.480397)
hotwater 0.1.2 0.400000 0.000000 0.400000 ( 0.396380)
amatch 0.3.0 1.030000 0.000000 1.030000 ( 1.028923)
jaro_winkler 1.4.0 0.320000 0.000000 0.320000 ( 0.320867)
fuzzystringmatch 0.9.7 0.460000 0.000000 0.460000 ( 0.473568)
hotwater 0.1.2 0.310000 0.000000 0.310000 ( 0.317671)
amatch 0.3.0 1.060000 0.000000 1.060000 ( 1.066627)
# Pure Ruby
Rehearsal ----------------------------------------------------------
jaro_winkler 1.4.0 0.680000 0.010000 0.690000 ( 0.690518)
fuzzystringmatch 0.9.7 1.610000 0.000000 1.610000 ( 1.608468)
------------------------------------------------- total: 2.300000sec
jaro_winkler 1.4.0 0.670000 0.010000 0.680000 ( 0.678950)
fuzzystringmatch 0.9.7 1.770000 0.000000 1.770000 ( 1.778839)
------------------------------------------------- total: 2.450000sec
user system total real
jaro_winkler 1.4.0 0.620000 0.000000 0.620000 ( 0.619257)
fuzzystringmatch 0.9.7 1.600000 0.010000 1.610000 ( 1.597612)
jaro_winkler 1.4.0 0.680000 0.010000 0.690000 ( 0.684852)
fuzzystringmatch 0.9.7 1.710000 0.000000 1.710000 ( 1.720497)
```

# Todo
Expand Down
11 changes: 7 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ task default: [:compile, :test]

task benchmark: %w[benchmark:native benchmark:pure]

task :print_ruby_version do
print "#{RUBY_DESCRIPTION}\n\n"
end

task :print_time do
puts Time.now.utc
puts
print "#{Time.now.utc}\n\n"
end

namespace :benchmark do
task :native => :print_time do |t, args|
task :native => [:print_time, :print_ruby_version] do |t, args|
puts '# C Extension'
load File.expand_path("../benchmark/native.rb", __FILE__)
puts
end

task :pure => :print_time do |t, args|
task :pure => [:print_time, :print_ruby_version] do |t, args|
puts '# Pure Ruby'
load File.expand_path("../benchmark/pure.rb", __FILE__)
puts
Expand Down
3 changes: 2 additions & 1 deletion benchmark/native.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
require 'benchmark'
require 'jaro_winkler'
require 'jaro_winkler/version'
require 'fuzzystringmatch'
require 'hotwater'
require 'amatch'
ary = [['al', 'al'], ['martha', 'marhta'], ['jones', 'johnson'], ['abcvwxyz', 'cabvwxyz'], ['dwayne', 'duane'], ['dixon', 'dicksonx'], ['fvie', 'ten']]

n = 100000
Benchmark.bmbm do |x|
x.report "jaro_winkler #{Gem.loaded_specs['jaro_winkler'].version}" do
x.report "jaro_winkler #{JaroWinkler::VERSION}" do
n.times{ ary.each{ |str1, str2| JaroWinkler.distance(str1, str2) } }
end

Expand Down
3 changes: 2 additions & 1 deletion benchmark/pure.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
require 'jaro_winkler/jaro_winkler_pure'
require 'jaro_winkler/version'
require 'benchmark'
require 'fuzzystringmatch'
ary = [['al', 'al'], ['martha', 'marhta'], ['jones', 'johnson'], ['abcvwxyz', 'cabvwxyz'], ['dwayne', 'duane'], ['dixon', 'dicksonx'], ['fvie', 'ten']]

n = 10000
Benchmark.bmbm do |x|
x.report "jaro_winkler #{Gem.loaded_specs['jaro_winkler'].version}" do
x.report "jaro_winkler #{JaroWinkler::VERSION}" do
n.times{ ary.each{ |str1, str2| JaroWinkler.distance(str1, str2) } }
end

Expand Down

0 comments on commit ce27575

Please sign in to comment.