[macruby-changes] [MacRuby/MacRuby] 7194f9: remove unnecessary condition in StringScanner beca...

noreply at github.com noreply at github.com
Tue Jun 28 18:14:06 PDT 2011


  Branch: refs/heads/master
  Home:   https://github.com/MacRuby/MacRuby

  Commit: 7194f96c2ef8a0aaa32de4042e677c6754ef47a5
      https://github.com/MacRuby/MacRuby/commit/7194f96c2ef8a0aaa32de4042e677c6754ef47a5
  Author: Watson <watson1978 at gmail.com>
  Date:   2011-06-28 (Tue, 28 Jun 2011)

  Changed paths:
    M lib/strscan.rb

  Log Message:
  -----------
  remove unnecessary condition in StringScanner because rest_size is always greater equal than 0.

* before
      user     system      total        real
length = 5000  0.340000   0.040000   0.380000 (  0.272269)
length = 10000  0.850000   0.120000   0.970000 (  0.659509)
length = 20000  2.610000   0.490000   3.100000 (  2.011090)

* after
      user     system      total        real
length = 5000  0.300000   0.030000   0.330000 (  0.233528)
length = 10000  0.730000   0.080000   0.810000 (  0.564157)
length = 20000  2.270000   0.430000   2.700000 (  1.806181)

{{{
require 'benchmark'
require 'strscan'

Benchmark.bm do |x|
  x.report "length = 5000" do
    str = "x" * 5000
    s = StringScanner.new(str)
    s.scan(/./) until s.eos?
  end

  x.report "length = 10000" do
    str = "x" * 10000
    s = StringScanner.new(str)
    s.scan(/./) until s.eos?
  end

  x.report "length = 20000" do
    str = "x" * 20000
    s = StringScanner.new(str)
    s.scan(/./) until s.eos?
  end
end
}}}




More information about the macruby-changes mailing list