Project

General

Profile

Actions

Feature #6311

closed

memmem()によるrb_memsearch()の高速化

Added by Glass_saga (Masaki Matsushita) about 12 years ago. Updated over 11 years ago.

Status:
Closed
Target version:
-
[ruby-dev:45530]

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

patch.diff (1.96 KB) patch.diff Glass_saga (Masaki Matsushita), 04/17/2012 11:32 PM
patch2.diff (2.46 KB) patch2.diff Glass_saga (Masaki Matsushita), 04/28/2012 01:34 PM
patch3.diff (2.23 KB) patch3.diff Glass_saga (Masaki Matsushita), 04/30/2012 11:36 AM
patch4.diff (1.73 KB) patch4.diff Glass_saga (Masaki Matsushita), 11/11/2012 02:46 PM
use_memchr.diff (442 Bytes) use_memchr.diff knu (Akinori MUSHA), 11/13/2012 02:58 PM
use_memchr2.diff (419 Bytes) use_memchr2.diff knu (Akinori MUSHA), 11/13/2012 03:12 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0