Sha256: 7bbc60357d950c1927f815b71ca890c0d7f6f63b8f63bdd638afecfb0b29d48e
Contents?: true
Size: 866 Bytes
Versions: 5
Compression:
Stored size: 866 Bytes
Contents
require "benchmark" require "string_metric" require "text" require "csv" if RUBY_ENGINE == "ruby" require "pry" end Benchmark.bmbm(7) do |x| iterations = 10_000 options = { insertion_cost: 2 } fixtures = [] CSV.foreach("spec/fixtures/levenshtein.csv") do |row| from, to, _ = row fixtures.push [from.to_s.strip, to.to_s.strip] end StringMetric::Levenshtein::STRATEGIES.each do |strategy, implementation| next if strategy == :recursive x.report("#{implementation.to_s} implementation") do iterations.times do |i| fixtures.each do |from, to| implementation.distance(from, to, options) end end end end x.report("Text::Levenshtein implementation") do iterations.times do |i| fixtures.each do |from, to| Text::Levenshtein.distance(from, to) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems