Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 24 lines (17 sloc) 0.526 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
# -*- encoding: utf-8 -*-

require "benchmark"

require "unicode_utils/titlecase"

TXT_DIR = File.join(File.dirname(__FILE__), "..", "test")

def read_txt(filename)
  File.read(File.join(TXT_DIR, filename), mode: "r:UTF-8:-")
end

german_text = read_txt("dreilaendereck.txt")
long_german_text = german_text * 30

Benchmark.bm(35) do |x|
  x.report "titlecase" do
    30.times { UnicodeUtils.titlecase(german_text) }
  end
  x.report "titlecase, long text" do
    1.times { UnicodeUtils.titlecase(long_german_text) }
  end
end
Something went wrong with that request. Please try again.