[Bug #736] Range#include? が遅い


#1

Bug #736: Range#include? e$B$,CY$$e(B
http://redmine.ruby-lang.org/issues/show/736

e$B5/I<<Te(B: rubikitch .
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal

Ruby 1.9e$B$Ge(BRange#include?e$B$,$b$N$9$4$$CY$$$h$&$G$9!#e(B

require benchmark
RUBY_VERSION # => 1.8.7
Benchmark.bmbm(10) do |b|
n = 100
b.report(include) { n.times{ (anruby).include? elf }}
b.report(between) { n.times{ elf.between?(an,ruby) }}
end

>> Rehearsal ---------------------------------------------

>> include 0.000000 0.000000 0.000000 ( 0.000278)

>> between 0.000000 0.000000 0.000000 ( 0.000113)

>> ------------------------------------ total: 0.000000sec

>>

>> user system total real

>> include 0.000000 0.000000 0.000000 ( 0.000233)

>> between 0.000000 0.000000 0.000000 ( 0.000113)

require benchmark
RUBY_VERSION # => 1.9.0
Benchmark.bmbm(10) do |b|
n = 100
b.report(include) { n.times{ (anruby).include? elf }}
b.report(between) { n.times{ elf.between?(an,ruby) }}
end

>> Rehearsal ---------------------------------------------

>> include 0.420000 0.000000 0.420000 ( 0.417621)

>> between 0.000000 0.000000 0.000000 ( 0.000116)

>> ------------------------------------ total: 0.420000sec

>>

>> user system total real

>> include 0.420000 0.000000 0.420000 ( 0.422576)

>> between 0.000000 0.000000 0.000000 ( 0.000120)


#2

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message Re: [ruby-dev:37051] [Bug #736] Range#include?
e$B$,CY$$e(B
on Mon, 10 Nov 2008 05:41:10 +0900, rubikitch .
removed_email_address@domain.invalid writes:

|Ruby 1.9e$B$Ge(BRange#include?e$B$,$b$N$9$4$$CY$$$h$&$G$9!#e(B

1.9e$B$G$Oe(Binclude?e$B$O$=$NCM$,e(Beache$B$5$l$kMWAG$K4^$^$l$k$+$I$&$+$re(B
e$B%A%%C%/$9$k$h$&$K$J$j$^$7$?!#$3$l$O0lHL$KBg>.4X78$NHf3Se(B(1.8
e$B$G$NHf3Se(B)e$B$h$j$b$b$N$9$4$$CY$$$N$O;EJ}$,$J$$$H;W$$$^$9!#e(B

  • between?
  • cover? (e$B?7@_e(B)

e$B$r;H$C$F$/$@$5$$!#e(B