-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fba1b2e
commit e6b93fb
Showing
3 changed files
with
43 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
$LOAD_PATH << File.expand_path('../../lib', __FILE__) | ||
require 'bundler' | ||
Bundler.setup(:benchmark) | ||
|
||
def gem_name_with_version(gem) | ||
"#{gem} (#{Gem.loaded_specs[gem].version})" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
require File.expand_path('../env', __FILE__) | ||
require 'benchmark' | ||
require 'jaro_winkler' | ||
require 'jaro_winkler/version' | ||
require 'jaro_winkler/jaro_winkler_ext' | ||
require 'fuzzystringmatch' | ||
require 'hotwater' | ||
require 'amatch' | ||
ary = [['al', 'al'], ['martha', 'marhta'], ['jones', 'johnson'], ['abcvwxyz', 'cabvwxyz'], ['dwayne', 'duane'], ['dixon', 'dicksonx'], ['fvie', 'ten']] | ||
|
||
n = 100000 | ||
ary = [ | ||
%w[al al], %w[martha marhta], %w[jones johnson], %w[abcvwxyz cabvwxyz], | ||
%w[dwayne duane], %w[dixon dicksonx], %w[fvie ten] | ||
] | ||
|
||
n = 100_000 | ||
|
||
Benchmark.bmbm do |x| | ||
x.report "jaro_winkler #{JaroWinkler::VERSION}" do | ||
n.times{ ary.each{ |str1, str2| JaroWinkler.distance(str1, str2) } } | ||
x.report "jaro_winkler (#{`git rev-parse --short HEAD`.chop!})" do | ||
n.times { ary.each { |str1, str2| JaroWinkler.distance(str1, str2) } } | ||
end | ||
|
||
x.report "fuzzystringmatch #{Gem.loaded_specs['fuzzy-string-match'].version}" do | ||
x.report gem_name_with_version('fuzzy-string-match') do | ||
jarow = FuzzyStringMatch::JaroWinkler.create(:native) | ||
n.times{ ary.each{ |str1, str2| jarow.getDistance(str1, str2) } } | ||
n.times { ary.each { |str1, str2| jarow.getDistance(str1, str2) } } | ||
end | ||
|
||
x.report "hotwater #{Gem.loaded_specs['hotwater'].version}" do | ||
n.times{ ary.each{ |str1, str2| Hotwater.jaro_winkler_distance(str1, str2) } } | ||
x.report gem_name_with_version('hotwater') do | ||
n.times { ary.each { |str1, str2| Hotwater.jaro_winkler_distance(str1, str2) } } | ||
end | ||
|
||
x.report "amatch #{Gem.loaded_specs['amatch'].version}" do | ||
n.times{ ary.each{ |str1, str2| Amatch::Jaro.new(str1).match(str2) } } | ||
x.report gem_name_with_version('amatch') do | ||
n.times { ary.each { |str1, str2| Amatch::Jaro.new(str1).match(str2) } } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
require 'jaro_winkler/jaro_winkler_pure' | ||
require 'jaro_winkler/version' | ||
# frozen_string_literal: true | ||
|
||
require File.expand_path('../env', __FILE__) | ||
require 'benchmark' | ||
require 'jaro_winkler/jaro_winkler_pure' | ||
require 'fuzzystringmatch' | ||
ary = [['al', 'al'], ['martha', 'marhta'], ['jones', 'johnson'], ['abcvwxyz', 'cabvwxyz'], ['dwayne', 'duane'], ['dixon', 'dicksonx'], ['fvie', 'ten']] | ||
|
||
n = 10000 | ||
ary = [ | ||
%w[al al], %w[martha marhta], %w[jones johnson], %w[abcvwxyz cabvwxyz], | ||
%w[dwayne duane], %w[dixon dicksonx], %w[fvie ten] | ||
] | ||
|
||
n = 10_000 | ||
|
||
Benchmark.bmbm do |x| | ||
x.report "jaro_winkler #{JaroWinkler::VERSION}" do | ||
n.times{ ary.each{ |str1, str2| JaroWinkler.distance(str1, str2) } } | ||
x.report "jaro_winkler (#{`git rev-parse --short HEAD`.chop!})" do | ||
n.times { ary.each { |str1, str2| JaroWinkler.distance(str1, str2) } } | ||
end | ||
|
||
x.report "fuzzystringmatch #{Gem.loaded_specs['fuzzy-string-match'].version}" do | ||
x.report gem_name_with_version('fuzzy-string-match') do | ||
jarow = FuzzyStringMatch::JaroWinkler.create(:pure) | ||
n.times{ ary.each{ |str1, str2| jarow.getDistance(str1, str2) } } | ||
n.times { ary.each { |str1, str2| jarow.getDistance(str1, str2) } } | ||
end | ||
end |