Skip to content

Instantly share code, notes, and snippets.

@nascimento
Created February 12, 2018 01:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nascimento/c952958f07d192fa1dcdbe3793d737e8 to your computer and use it in GitHub Desktop.
Save nascimento/c952958f07d192fa1dcdbe3793d737e8 to your computer and use it in GitHub Desktop.
Mult Thread to Stress service with Ruby
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