instiki/vendor/plugins/maruku/miscs/test.rb
Jacques Distler 13a522525c REXML is dead. Long live Nokogiri.
Modify Maruku to use Nokogiri instead of REXML.
Produces a 3-fold speedup in the #to_html method.
2011-08-11 20:36:44 -05:00

29 lines
344 B
Ruby

n=100
$buffer = "blah "*n+"boh"+"beh"*n
$index = n*5
def fun1(reg)
r2 = /^.{#{$index}}#{reg}/
r2.match($buffer)
end
def fun2(reg)
reg.match($buffer[$index, $buffer.size-$index])
end
r = /\w*/
a = Time.now
1000.times do
fun1(r)
end
b = Time.now
1000.times do
fun2(r)
end
c = Time.now
puts "fun1: #{b-a} sec"
puts "fun2: #{c-b} sec"