#1410: String#length is slow when invoke at first time. ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Test Script: {{{ #!ruby require 'benchmark' Benchmark.bm(15) do |x| str = "abcdef" * 10000000 x.report "#size" do str.size end x.report "#length (1)" do # first time str.length end x.report "#length (2)" do # second time str.length end str2 = str.dup x.report "#length (3)" do str2.length end end }}} Result: {{{ $ macruby bm_str_length.rb user system total real #size 0.000000 0.000000 0.000000 ( 0.000012) #length (1) 0.000000 0.000000 0.000000 ( 0.001750) #length (2) 0.000000 0.000000 0.000000 ( 0.000008) #length (3) 0.000000 0.000000 0.000000 ( 0.000010) }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1410> MacRuby <http://macruby.org/>