Created
February 12, 2018 01:28
-
-
Save nascimento/c952958f07d192fa1dcdbe3793d737e8 to your computer and use it in GitHub Desktop.
Mult Thread to Stress service with Ruby
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 'mechanize' | |
require 'open-uri' | |
require 'rubygems' | |
require 'work_queue' | |
wq = WorkQueue.new 1000 | |
(1..5000).each do |number| | |
#beginning = Time.now | |
wq.enqueue_b do | |
a = Mechanize.new { |agent| | |
agent.user_agent_alias = 'Mac Safari' | |
} | |
a.get('http://localhost/NDAxMTc0') do |page| | |
end | |
end | |
#puts "#{number} - Time elapsed #{Time.now - beginning} seconds\n" | |
puts "#{number}" | |
end | |
wq.join | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment