require 'timeout'
class Float
def times
whole, frac = divmod 1
avg = whole.times.reduce(0) { |elapsed,|
t = Time.now
yield
Time.now - t + elapsed
} / whole
Timeout.timeout(avg * frac) { yield }
rescue Timeout::Error
end
end
2.5.times do
'This is a test'.each_char do |char|
print char
sleep 0.01
end
puts
end