Sha256: 1177e9834b081c374b0e213cc1371d6f960a4d0eb2961100f5560a804084f4ab

Contents?: true

Size: 1.21 KB

Versions: 23

Compression:

Stored size: 1.21 KB

Contents

require File.expand_path(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://127.0.0.1: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://127.0.0.1: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

23 entries across 23 versions & 2 rubygems

Version Path
curb-1.0.3 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-1.0.2 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-1.0.1 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-1.0.0 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.9.11 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.9.10 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.9.9 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.9.8 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.9.7 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.9.6 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.9.5 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.9.4 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.9.3 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.9.2 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.9.1 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.9.0 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.8.8 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.8.7 tests/bug_curb_easy_blocks_ruby_threads.rb
gus-curb-0.8.7 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.8.6 tests/bug_curb_easy_blocks_ruby_threads.rb