From: Siep Korteling Date: 2010-03-13T06:14:29+09:00 Subject: Re: Ruby Regexp implementation? Aldric Giacomoni wrote: > This probably doesn't belong in Ruby Core. I was reading this article: > http://swtch.com/~rsc/regexp/regexp1.html > http://swtch.com/~rsc/regexp/regexp2.html > http://swtch.com/~rsc/regexp/regexp3.html > > And in the first few lines of the first page, it shows that the Regexp > implementation for Perl is absolutely terrible, and it says that Ruby is > "the same" or at least similar. Is Ruby 1.8 / 1.9 using the Thompson NFA > matching? Will Ruby 2.0 use it? def pathologicalize (str, n) tmp = str[0]*n [str*n + tmp, tmp] end puts RUBY_VERSION 1.step(101, 10) do |n| full_str, part_str = pathologicalize("a?", n) start = Time.now 1000.times do full_str =~ /#{part_str}/ end duration = Time.now-start puts "#{n}:\t#{duration}" end #output 1.9.1 1: 0.015625 11: 0.015625 21: 0.015625 31: 0.03125 41: 0.03125 51: 0.046875 61: 0.046875 71: 0.046875 81: 0.0625 91: 0.0625 101: 0.078125 Siep -- Posted via http://www.ruby-forum.com/.