mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-05-28 07:47:03 +08:00
add benchmarks for String
This commit is contained in:
25
test/Benchmark/app/benchmark/string/include.rb
Normal file
25
test/Benchmark/app/benchmark/string/include.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
def string_include(x)
|
||||
x.report "include? with ASCII match" do
|
||||
100000.times do
|
||||
$short_sentence_ascii.include?("Candahar")
|
||||
end
|
||||
end
|
||||
|
||||
x.report "include? with ASCII nomatch" do
|
||||
100000.times do
|
||||
$short_sentence_ascii.include?("abcde")
|
||||
end
|
||||
end
|
||||
|
||||
x.report "include? with UTF8 match" do
|
||||
100000.times do
|
||||
$short_sentence_utf8.include?("ロンドン")
|
||||
end
|
||||
end
|
||||
|
||||
x.report "include? with UTF8 nomatch" do
|
||||
100000.times do
|
||||
$short_sentence_utf8.include?("日本")
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user