Skip to content

Instantly share code, notes, and snippets.

@saivenkat
Created November 29, 2009 10:35
Show Gist options
  • Select an option

  • Save saivenkat/244875 to your computer and use it in GitHub Desktop.

Select an option

Save saivenkat/244875 to your computer and use it in GitHub Desktop.
A url timer using NeverBlock
require "neverblock"
require "net/http"
require "uri"
def load_timer(url, number_of_requests=50)
@pool = NB::Pool::FiberPool.new(number_of_requests)
start = Time.now
number_of_requests.times do
@pool.spawn do
request_url = URI.parse(url)
res = Net::HTTP.start(request_url.host, request_url.port) {|http| http.ge>
end
end
finish = Time.now
puts "Total time - #{finish - start} seconds"
end
if $0 == __FILE__
load_timer "http://localhost:9999", 20
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment