Created
May 26, 2009 10:50
-
-
Save jarib/118007 to your computer and use it in GitHub Desktop.
This file contains 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 "rubygems" | |
require "celerity" | |
threads = [] | |
threads << Thread.new do | |
# en ny browser per tråd | |
browser = Celerity::Browser.new | |
browser.goto "http://" | |
# osv | |
end | |
threads.each { |t| t.join } # vent til alle trådene er ferdig |
This file contains 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 "rubygems" | |
require "celerity" | |
# viktig, ellers "slukes" alle feil som kastes i trådene | |
Thread.abort_on_exception = true | |
class HotelSearcher | |
def execute(number_of_users) | |
threads = [] | |
number_of_users.times do | |
threads << Thread.new { random_hotel_search } | |
end | |
threads.each { |t| t.join } | |
end | |
def random_hotel_search | |
browser = Celerity::Browser.new | |
browser.goto "http://...." | |
# osv | |
end | |
end | |
hs = HotelSearcher.new | |
hs.execute(50) # kan bli litt tungt for CPUen dette.. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment