Sha256: 55a39e724f16606697bcc979649667de8e4fe2c210ed2ce43333eaa7c25b609c

Contents?: true

Size: 1.19 KB

Versions: 22

Compression:

Stored size: 1.19 KB

Contents

require File.join(File.dirname(__FILE__), 'helper')
require 'webrick'
class ::WEBrick::HTTPServer ; def access_log(config, req, res) ; end ; end
class ::WEBrick::BasicLog ; def log(level, data) ; end ; end

class BugTestInstancePostDiffersFromClassPost < Test::Unit::TestCase
  def test_bug
    server = WEBrick::HTTPServer.new( :Port => 9999 )
    server.mount_proc("/test") do|req,res|
      sleep 0.5
      res.body = "hi"
      res['Content-Type'] = "text/html"
    end

    thread = Thread.new(server) do|srv|
      srv.start
    end

    threads = []
    timer = Time.now

    5.times do |i|
      t = Thread.new do
        c = Curl::Easy.perform('http://localhost:9999/test')
        c.header_str
      end
      threads << t
    end

    multi_responses = threads.collect do|t|
      t.value
    end

    multi_time = (Time.now - timer)
    puts "requested in #{multi_time}"

    timer = Time.now
    single_responses = []
    5.times do |i|
      c = Curl::Easy.perform('http://localhost:9999/test')
      single_responses << c.header_str
    end
    
    single_time = (Time.now - timer)
    puts "requested in #{single_time}"

    assert single_time > multi_time

    server.shutdown
    thread.join
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
taf2-curb-0.2.7.4 tests/bug_curb_easy_blocks_ruby_threads.rb
taf2-curb-0.2.8.0 tests/bug_curb_easy_blocks_ruby_threads.rb
taf2-curb-0.3.0.0 tests/bug_curb_easy_blocks_ruby_threads.rb
taf2-curb-0.3.5.0 tests/bug_curb_easy_blocks_ruby_threads.rb
taf2-curb-0.3.6.0 tests/bug_curb_easy_blocks_ruby_threads.rb
taf2-curb-0.4.0.0 tests/bug_curb_easy_blocks_ruby_threads.rb
taf2-curb-0.4.1.0 tests/bug_curb_easy_blocks_ruby_threads.rb
taf2-curb-0.4.2.0 tests/bug_curb_easy_blocks_ruby_threads.rb
taf2-curb-0.4.3.0 tests/bug_curb_easy_blocks_ruby_threads.rb
taf2-curb-0.4.4.0 tests/bug_curb_easy_blocks_ruby_threads.rb
taf2-curb-0.4.5.0 tests/bug_curb_easy_blocks_ruby_threads.rb
taf2-curb-0.4.6.0 tests/bug_curb_easy_blocks_ruby_threads.rb
taf2-curb-0.4.8.0 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.3.7 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.4.2.0 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.4.4.0 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.4.8.0 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.3.1 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.3.3 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.3.5 tests/bug_curb_easy_blocks_ruby_threads.rb