def timeThis
    startTime = Time.now()
    yield
    endTime = Time.now()
    endTime.to_f() - startTime.to_f()
end
puts(timeThis{sleep(0.25)})

Displays (standard out)0.25