在ruby中测量页面加载/处理时间

Rad*_*dek 1 ruby

我需要运行这个PHP脚本 http://db2express/imacs/radek/3.1/rationalTest.php?mode=create

处理时间大约是10分钟左右,它streams的浏览器输出是它的作用.它正在创建和设置数据库,创建索引等.

如何衡量处理完全加载此页面需要多长时间?

我需要从ruby运行页面.还捕获输出.

Bil*_*ber 5

如果你喜欢unix,你可以这样做

time curl "http://db2express/imacs/radek/3.1/rationalTest.php?mode=create" > output.html
Run Code Online (Sandbox Code Playgroud)

如果你真的需要从红宝石做...

require 'open-uri'
require 'date'

url = "http://db2express/imacs/radek/3.1/rationalTest.php?mode=create"

start = Time.new
f = open(url).read
stop = Time.new

puts "Time elapsed: #{stop - start} seconds"
puts "The content of the file is:\n#{f}"
Run Code Online (Sandbox Code Playgroud)