I updated the patch (range_eqq2.patch).
It optimize only special cases.
Range with Fixnum¶
i = 0
while i < 10_000_000
case i
when 1..1000
end
i += 1
end
Before¶
$ time ./miniruby t.rb
./miniruby t.rb 5.27s user 0.02s system 98% cpu 5.354 total
After¶
$ time ./miniruby t.rb
./miniruby t.rb 4.45s user 0.04s system 96% cpu 4.644 total
Range with String¶
i = 0
while i < 10_000_000
case "c"
when "a".."z"
end
i += 1
end
Before¶
$ time ./miniruby t.rb
./miniruby t.rb 8.45s user 0.02s system 99% cpu 8.534 total
After¶
$ time ./miniruby t.rb
./miniruby t.rb 3.80s user 0.01s system 98% cpu 3.874 total
Of course, test-all passed.
$ make test-all TESTS=test/ruby/test_range.rb
./tool/ifchange "--timestamp=.rbconfig.time" rbconfig.rb rbconfig.tmp
rbconfig.rb unchanged
creating verconf.h
verconf.h updated
compiling loadpath.c
linking static-library libruby.2.5.0-static.a
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: libruby.2.5.0-static.a(debug_counter.o) has no symbols
linking shared-library libruby.2.5.0.dylib
linking ruby
Run options: "--ruby=./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems" --excludes-dir=./test/excludes --name=!/memory_leak/
# Running tests:
Finished tests in 2.777357s, 14.7622 tests/s, 144652.6320 assertions/s.
41 tests, 401752 assertions, 0 failures, 0 errors, 0 skips
ruby -v: ruby 2.5.0dev (2017-05-17 trunk 58600) [x86_64-darwin16]