Sha256: ad18119a48025a84c6780ac9f77e73b74ce2f9d0c60bfd5718ef91b87be27660
Contents?: true
Size: 561 Bytes
Versions: 10
Compression:
Stored size: 561 Bytes
Contents
# coding : utf-8 require 'benchmark' require 'turkish_stemmer' Benchmark.bmbm(7) do |x| x.report('regex') do TurkishStemmer.class_eval do def self.turkish?(word) !! word.match(TurkishStemmer::ALPHABET) end end 100_000.times { TurkishStemmer.turkish?("aaa") } end x.report('loop') do TurkishStemmer.class_eval do def self.turkish?(word) !! word.chars.to_a.all? { |c| "abcçdefgğhıijklmnoöprsştuüvyz".include?(c) } end end 100_000.times { TurkishStemmer.turkish?("aaaa") } end end
Version data entries
10 entries across 10 versions & 1 rubygems