Skip to content

Instantly share code, notes, and snippets.

@igrigorik
Created March 27, 2011 01:59
Show Gist options
  • Save igrigorik/888841 to your computer and use it in GitHub Desktop.
Save igrigorik/888841 to your computer and use it in GitHub Desktop.
run N requests with X concurrency
require 'em-synchrony'
require 'em-synchrony/em-http'
EM.synchrony do
EM::Synchrony::Iterator.new(1..ARGV[0].to_i, ARGV[1].to_i).each do |num, iter|
c = EM::HttpRequest.new('http://127.0.0.1:9000/').aget
c.callback {iter.next}
end
EM.stop
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment