forked from MacRuby/MacRuby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve the performance of String#length with multi-byte character st…
…ring * before user system total real ascii 0.000000 0.000000 0.000000 ( 0.002556) utf8 2.340000 0.000000 2.340000 ( 2.344955) utf8 (dup) 3.580000 0.640000 4.220000 ( 3.584336) * after user system total real ascii 0.000000 0.000000 0.000000 ( 0.002540) utf8 0.010000 0.000000 0.010000 ( 0.003444) utf8 (dup) 0.600000 0.780000 1.380000 ( 1.324915) Test Script ---- # -*- coding: utf-8 -*- require 'benchmark' str_ascii = "abcdefghij" * 100000 str_utf8 = "あいうえお" * 100000 Benchmark.bm(10) do |x| x.report "ascii" do 1000.times do str_ascii.length end end x.report "utf8" do 1000.times do str_utf8.length end end x.report "utf8 (dup)" do 1000.times do str_utf8.dup.length end end end
- Loading branch information
1 parent
9c78016
commit 67e47b9
Showing
2 changed files
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters