File: server_perf_spec.rb

package info (click to toggle)
thin 1.3.1-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,084 kB
  • sloc: ruby: 4,138; ansic: 1,537; sh: 82; makefile: 8
file content (39 lines) | stat: -rw-r--r-- 1,005 bytes parent folder | download | duplicates (2)
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
28
29
30
31
32
33
34
35
36
37
38
39
require 'spec_helper'

describe Server, 'performance' do
  before do
    start_server do |env|
      body = env.inspect + env['rack.input'].read
      [200, { 'Content-Length' => body.size.to_s }, body]
    end
  end
  
  it "should handle GET in less then #{get_request_time = 0.0045} RubySecond" do
    proc { get('/') }.should be_faster_then(get_request_time)
  end
  
  it "should handle POST in less then #{post_request_time = 0.007} RubySecond" do
    proc { post('/', :file => 'X' * 1000) }.should be_faster_then(post_request_time)
  end
  
  after do
    stop_server
  end
end

describe Server, 'UNIX socket performance' do
  before do
    start_server('/tmp/thin_test.sock') do |env|
      body = env.inspect + env['rack.input'].read
      [200, { 'Content-Length' => body.size.to_s }, body]
    end
  end
  
  it "should handle GET in less then #{get_request_time = 0.002} RubySecond" do
    proc { get('/') }.should be_faster_then(get_request_time)
  end
  
  after do
    stop_server
  end
end