Created
November 29, 2009 10:35
-
-
Save saivenkat/244875 to your computer and use it in GitHub Desktop.
A url timer using NeverBlock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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