public
Rubygem
Description: Ruby bindings for libcurl
Homepage: http://idle-hacking.com/
Clone URL: git://github.com/taf2/curb.git
use a local webrick instance instead of google for timing
taf2 (author)
Fri Aug 08 15:58:43 -0700 2008
commit  b71186b45e9a0ac604ba17fe08cc0277af167372
tree    9f528d21b5e3f2e853af380e5ecf2a2b32a01386
parent  e7ae2a8107ec8c594a4847168c32a1da6bdc7441
...
1
 
 
 
2
3
4
 
 
 
 
 
 
 
 
 
 
 
5
6
7
8
9
10
 
11
12
13
...
23
24
25
26
 
27
28
29
...
31
32
33
 
 
 
34
35
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
24
25
26
27
...
37
38
39
 
40
41
42
43
...
45
46
47
48
49
50
51
52
0
@@ -1,13 +1,27 @@
0
 require File.join(File.dirname(__FILE__), 'helper')
0
+require 'webrick'
0
+class ::WEBrick::HTTPServer ; def access_log(config, req, res) ; end ; end
0
+class ::WEBrick::BasicLog ; def log(level, data) ; end ; end
0
 
0
 class BugTestInstancePostDiffersFromClassPost < Test::Unit::TestCase
0
   def test_bug
0
+ server = WEBrick::HTTPServer.new( :Port => 9999 )
0
+ server.mount_proc("/test") do|req,res|
0
+ sleep 0.5
0
+ res.body = "hi"
0
+ res['Content-Type'] = "text/html"
0
+ end
0
+
0
+ thread = Thread.new(server) do|srv|
0
+ srv.start
0
+ end
0
+
0
     threads = []
0
     timer = Time.now
0
 
0
     5.times do |i|
0
       t = Thread.new do
0
- c = Curl::Easy.perform('http://www.google.com/')
0
+ c = Curl::Easy.perform('http://localhost:9999/test')
0
         c.header_str
0
       end
0
       threads << t
0
@@ -23,7 +37,7 @@ class BugTestInstancePostDiffersFromClassPost < Test::Unit::TestCase
0
     timer = Time.now
0
     single_responses = []
0
     5.times do |i|
0
- c = Curl::Easy.perform('http://www.google.com/')
0
+ c = Curl::Easy.perform('http://localhost:9999/test')
0
       single_responses << c.header_str
0
     end
0
     
0
@@ -31,5 +45,8 @@ class BugTestInstancePostDiffersFromClassPost < Test::Unit::TestCase
0
     puts "requested in #{single_time}"
0
 
0
     assert single_time > multi_time
0
+
0
+ server.shutdown
0
+ thread.join
0
   end
0
 end

Comments

    No one has commented yet.