bin/benchmark
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/inline'
gemfile true, quiet: true do
source 'https://rubygems.org'
gemspec
gem 'benchmark-ips'
gem 'benchmark-memory'
gem 'sixarm_ruby_unaccent'
end
strings = [
'String without accents in english',
'Streng med aksenter på norsk',
'Řetězec s akcenty v češtině',
'Chaîne avec accents en français',
'Cuerda con acentos en español',
'Corda amb accents en català',
'Stīga ar akcentiem latviešu valodā',
'Türkçe aksanlı dize',
'Varg me theks në shqip',
'Κείμενο με τόνους στα ελληνικά'
]
reports = lambda do |x|
x.report('unaccent') do
strings.each do |str|
Unaccent.unaccent(str)
end
end
x.report('sixarm') do
strings.each(&:unaccent)
end
end
Benchmark.ips do |x|
reports.call(x)
x.compare!
end
Benchmark.memory do |x|
reports.call(x)
x.compare!
end