Top Level Namespace

Defined Under Namespace

Modules: Evdispatch Classes: TestApp, TestRequests

Constant Summary collapse

TEST_PORT =
4044

Instance Method Summary collapse

Instance Method Details

#request_bytes_from(d, base, amount, range) ⇒ Object



33
34
35
36
37
38
39
40
# File 'ext/revdispatch/test.rb', line 33

def request_bytes_from( d, base, amount, range )
  ids = []
  amount.times do|i|
    am = rand( range )
    ids << d.request_http( base + "bytes/#{am}/" )
  end
  ids
end

#request_delay_from(d, base, amount, delay) ⇒ Object



42
43
44
45
46
47
48
49
# File 'ext/revdispatch/test.rb', line 42

def request_delay_from( d, base, amount, delay )
  ids = []
  amount.times do|i|
    am = rand( delay )
    ids << d.request_http( base + "delay/#{delay}/" )
  end
  ids
end

#run_trialObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'ext/revdispatch/test.rb', line 51

def run_trial

  d = Evdispatch::Loop.new

  # start the event loop thread
  d.start


  timer = Time.now
  # send a dispatch http request and store a handle to the request
  google_id = d.request_http("http://www.google.com/")

  # do some processing and later on check for the response
  response = d.response( google_id )
  puts "Requested: #{response[:name]} in #{Time.now - timer} seconds"

  ebbbase = "http://127.0.0.1:4044/"
  timer = Time.now
  ids = request_bytes_from( d, ebbbase, 300, 10000 )
  #ids += request_delay_from( d, ebbbase, 100, 1 )

  # wait for each response
  puts "expecting #{ids.size} responses..."
  ids.each do|id|
    response = d.response( id )
    #puts response[:name]
    ObjectSpace.garbage_collect
  end

  puts "recieved #{ids.size} responses in #{Time.now - timer} seconds"

  # sometime later you can stop the event loop
  d.stop
end