Project

General

Profile

Bug #18144 » no_timeout.rb

duerst (Martin Dürst), 09/02/2021 06:44 AM

 
require 'timeout'

text = '"a' * 80_000
re = "[\"']([^\"']+)[\"'].*END"
puts re.inspect
regexp = Regexp.compile(re)
match = nil
t1 = t2 = 0
begin
Timeout::timeout(10) do
t1 = Time.now
match = text.match regexp
t2 = Time.now
end
puts "match: #{!!match}, time: #{t2-t1}"
rescue Timeout::Error
puts "timeout"
end

    (1-1/1)