Sha256: 1cddfca186368ce8eb07f154dc95d7441525dee8217c353de3c93df08303401e

Contents?: true

Size: 1.21 KB

Versions: 64

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://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

64 entries across 64 versions & 6 rubygems

Version Path
taf2-curb-0.4.9.0 tests/bug_curb_easy_blocks_ruby_threads.rb
taf2-curb-0.5.0.0 tests/bug_curb_easy_blocks_ruby_threads.rb
taf2-curb-0.5.1.0 tests/bug_curb_easy_blocks_ruby_threads.rb
taf2-curb-0.5.2.0 tests/bug_curb_easy_blocks_ruby_threads.rb
taf2-curb-0.5.4.0 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.8.2 tests/bug_curb_easy_blocks_ruby_threads.rb
codders-curb-0.8.0 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.8.1 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.8.0 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.7.18 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.7.17 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.7.16 tests/bug_curb_easy_blocks_ruby_threads.rb
ghazel-curb-0.7.15.1 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.7.15 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.7.14 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.7.13 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.7.12 tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.7.11 tests/bug_curb_easy_blocks_ruby_threads.rb
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/curb-0.7.8/tests/bug_curb_easy_blocks_ruby_threads.rb
curb-0.7.10 tests/bug_curb_easy_blocks_ruby_threads.rb