Skip to content

Instantly share code, notes, and snippets.

@jarib
Created May 26, 2009 10:50
Show Gist options
  • Save jarib/118007 to your computer and use it in GitHub Desktop.
Save jarib/118007 to your computer and use it in GitHub Desktop.
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
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