Measure response time for a HTTP request using Ruby
As mentioned in the comments, ruby has a benchmark module
require "benchmark"
time = Benchmark.measure do
#requests
end
Net::HTTP doesn't track response time, since it's not its job.
Before and after your request use Time.now
to set start and end times:
start_time = Time.now
# ...do request...
elapsed_time = Time.now - start_time
If you want to average that, add the elapsed_time
values together and divide by the number of tests:
total_time += elapsed_time
# ... do some stuff...
average_time = total_time / num_of_iterations
Time measures down to the micro-second, which should be plenty accurate for your needs.
You're on your own for the interface as that's an entirely different subject and would constitute a book.