require 'benchmark'
require 'turkish_stemmer'

Benchmark.bmbm(7) do |x|
  x.report('regex') do
    10000.times { "aaaaaaaaaa" =~ /^[#{TurkishStemmer::ALPHABET}]+$/ }
  end

  x.report('loop') do
    10000.times { "aaaaaaaaaa".chars.to_a.all? { |c| TurkishStemmer::ALPHABET.include?(c) } }
  end
end

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

Update turkish word recognition benchmark
Update turkish word recognition benchmark
