Feature #6311
closedmemmem()によるrb_memsearch()の高速化
Description
[Feature #6129][ruby-dev:45344]と類似していますが、memmem()によるre.cのrb_memsearch()の高速化を試みました。
次のベンチマークを実行したところ以下の結果となり、有意な性能向上がみられました。
require 'benchmark'
str = "hoge" * 10000 + "fugafuga"
Benchmark.bm do |x|
x.report do
1000.times { str.index("fugafuga") }
end
end
trunk(r35363):
user system total real
0.070000 0.000000 0.070000 ( 0.072126)
user system total real
0.070000 0.010000 0.080000 ( 0.081420)
user system total real
0.080000 0.000000 0.080000 ( 0.091658)
proposal:
user system total real
0.000000 0.000000 0.000000 ( 0.004237)
user system total real
0.000000 0.000000 0.000000 ( 0.003737)
user system total real
0.010000 0.000000 0.010000 ( 0.004696)
patchを添付します。
Files