From: Jim Freeze Date: 2002-10-07T08:54:13+09:00 Subject: Re: Speed of Ruby/modruby vs PHP On Sun, Oct 06, 2002 at 05:07:25PM -0400, Jim Freeze wrote: > Ok, here is how I understand this. > Does this look correct? > > In httpd.conf > > > RubyRequire apache/ruby-run > RubyRequire apache/eruby-run > RubyRequire apache/preload_timetest.rb # contains MyApp class > > # If URL is: http://www.mysite/preload_timetest > RubyHandler Apache::MyApp # Call Apache::MyApp.handler ?? > > > > SetHandler ruby-object > RubyHandler Apache::ERubyRun.instance > > > > Although no code is required in DocumentRoot > when running preloaded scripts, here is the > standard layout for the above declarations: > > mysite > +-htdocs > *.rhtml - these get executed as ruby files using eruby. > Ok, I did all the above and it works from a browser, but Net::HTTP is not happy with me. It gives the following error when I try to time the page: ./http_speed.rb mysite /preload_timetest /usr/local/lib/ruby/1.6/net/http.rb:1177:in `read_status': wrong status line: (Net::HTTPBadResponse) from ./http_speed.rb:48:in `join' from ./http_speed.rb:48 from ./http_speed.rb:48:in `each' from ./http_speed.rb:48 And http_speed.rb is: 25 def time_page(server, port, path) 26 time_start = Time.now 27 begin 28 Net::HTTP.start( server, port ) { |http| 29 response, = http.get(path) 30 # print response.body 31 } 32 rescue Net::ProtoRetriableError => err 33 if m = %r.match( err.response['location'] ) then 34 server = m[1].strip 35 path = m.post_match 36 retry 37 end 38 end 39 time = Time.now - time_start 40 end 41 42 times = [] 43 threads = [] 44 simul.times { |i| 45 threads << Thread.new(i) { times << time_page(server,port,path)} 46 sleep .3 47 } 48 threads.each {|t| t.join } 49 Any ideas? -- Jim Freeze