Skip to content

Instantly share code, notes, and snippets.

@xcsrz
Created November 5, 2014 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xcsrz/2957d733e52810be93f1 to your computer and use it in GitHub Desktop.
Save xcsrz/2957d733e52810be93f1 to your computer and use it in GitHub Desktop.
Just a little script to time page requests (no assets, just the single URL). It runs via /usr/bin/ruby which is present on all macs and most posix systems these days. If you're using rvm you'll probably want to change that.
#!/usr/bin/ruby
$url = ARGV[0]
$rounds = ARGV[1] || 10
loadTimes = []
puts "fetching page #{$rounds} times ..."
$rounds.to_i.times do
print "."
loadTimes << (`curl -w '%{time_total}\n' -o /dev/null -s "#{$url}"`).to_f
end
puts "... average request time: #{loadTimes.inject{ |sum, el| sum + el }.to_f / loadTimes.size}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment