[MacRuby/MacRuby] 67e47b: improve the performance of String#length with mult...
Branch: refs/heads/master Home: https://github.com/MacRuby/MacRuby Commit: 67e47b989eb8560f608b0a1a6393650259bec531 https://github.com/MacRuby/MacRuby/commit/67e47b989eb8560f608b0a1a6393650259... Author: Watson <watson1978@gmail.com> Date: 2012-06-06 (Wed, 06 Jun 2012) Changed paths: M encoding.h M string.c Log Message: ----------- improve the performance of String#length with multi-byte character string * 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
participants (1)
-
GitHub