tmm1 (owner)

Revisions

  • 73a948 tmm1 Sat Jun 06 01:39:59 -0700 2009
gist: 124776 Download_button fork
public
Description:
simple em stress test
Public Clone URL: git://gist.github.com/124776.git
Embed All Files: show embed
em_test.rb #
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
$conns = 10_000
 
require 'eventmachine'
 
module Server
  def post_init
  end
 
  def receive_data(data)
    send_data(data)
  end
 
  def unbind
  end
end
 
module Client
  def connection_completed
    send_data 'test'
  end
 
  def receive_data(data)
    close_connection
  end
 
  def unbind
    return EM.connect '127.0.0.1', 9999, Client unless ($conns -= 1) <= 0
    EM.stop
  end
end
 
EM.run do
  EM.start_server '127.0.0.1', 9999, Server
  EM.connect '127.0.0.1', 9999, Client
end