Skip to content

Instantly share code, notes, and snippets.

@trptcolin
Forked from blakesmith/test_script.rb
Created March 22, 2012 03:30
Show Gist options
  • Select an option

  • Save trptcolin/2155418 to your computer and use it in GitHub Desktop.

Select an option

Save trptcolin/2155418 to your computer and use it in GitHub Desktop.

Revisions

  1. trptcolin revised this gist Mar 22, 2012. 1 changed file with 15 additions and 6 deletions.
    21 changes: 15 additions & 6 deletions test_script.rb
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,26 @@
    #!/usr/bin/env ruby

    require 'thread'

    require 'rubygems'
    require 'typhoeus'

    100000.times do |t|
    mutex = Mutex.new

    100000.times do |t|
    Thread.new do
    puts "requesting - #{t}"
    @req = Typhoeus::Request.new("http://#{ARGV[0]}:#{ARGV[1]}",
    req = Typhoeus::Request.new("http://#{ARGV[0]}:#{ARGV[1]}",
    :method => :post,
    :body => "something=somethingelse")

    # this is still problematic: see all the shared state in
    # https://github.com/dbalatero/typhoeus/blob/master/lib/typhoeus/hydra.rb
    Typhoeus::Hydra.hydra.queue req

    mutex.synchronize do
    Typhoeus::Hydra.hydra.run
    end

    Typhoeus::Hydra.hydra.queue @req
    Typhoeus::Hydra.hydra.run
    end
    end
    end
    end
  2. @blakesmith blakesmith revised this gist Mar 22, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion test_script.rb
    Original file line number Diff line number Diff line change
    @@ -13,5 +13,5 @@

    Typhoeus::Hydra.hydra.queue @req
    Typhoeus::Hydra.hydra.run
    end.join
    end
    end
  3. @blakesmith blakesmith created this gist Mar 22, 2012.
    17 changes: 17 additions & 0 deletions test_script.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/usr/bin/env ruby

    require 'rubygems'
    require 'typhoeus'

    100000.times do |t|
    Thread.new do
    puts "requesting - #{t}"
    @req = Typhoeus::Request.new("http://#{ARGV[0]}:#{ARGV[1]}",
    :method => :post,
    :body => "something=somethingelse")


    Typhoeus::Hydra.hydra.queue @req
    Typhoeus::Hydra.hydra.run
    end.join
    end
    8 changes: 8 additions & 0 deletions test_server.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    #!/usr/bin/env ruby

    require 'rubygems'
    require 'sinatra'

    post '/' do
    "hello there!"
    end