Class: Roma::Test::Stress
- Inherits:
-
Object
- Object
- Roma::Test::Stress
- Defined in:
- lib/roma/tools/test-scenario.rb
Instance Attribute Summary collapse
-
#cnt ⇒ Object
readonly
Returns the value of attribute cnt.
-
#num_of_threads ⇒ Object
readonly
Returns the value of attribute num_of_threads.
-
#runnable ⇒ Object
Returns the value of attribute runnable.
-
#tmax ⇒ Object
readonly
Returns the value of attribute tmax.
-
#tmin ⇒ Object
readonly
Returns the value of attribute tmin.
Instance Method Summary collapse
-
#initialize(th_num) ⇒ Stress
constructor
A new instance of Stress.
- #start(addr, port) ⇒ Object
Constructor Details
#initialize(th_num) ⇒ Stress
Returns a new instance of Stress.
37 38 39 40 41 42 43 |
# File 'lib/roma/tools/test-scenario.rb', line 37 def initialize th_num @cnt = 0 @tmax = 0 @tmin = 100 @num_of_threads = th_num @runnable = true end |
Instance Attribute Details
#cnt ⇒ Object (readonly)
Returns the value of attribute cnt.
31 32 33 |
# File 'lib/roma/tools/test-scenario.rb', line 31 def cnt @cnt end |
#num_of_threads ⇒ Object (readonly)
Returns the value of attribute num_of_threads.
34 35 36 |
# File 'lib/roma/tools/test-scenario.rb', line 34 def num_of_threads @num_of_threads end |
#runnable ⇒ Object
Returns the value of attribute runnable.
35 36 37 |
# File 'lib/roma/tools/test-scenario.rb', line 35 def runnable @runnable end |
#tmax ⇒ Object (readonly)
Returns the value of attribute tmax.
32 33 34 |
# File 'lib/roma/tools/test-scenario.rb', line 32 def tmax @tmax end |
#tmin ⇒ Object (readonly)
Returns the value of attribute tmin.
33 34 35 |
# File 'lib/roma/tools/test-scenario.rb', line 33 def tmin @tmin end |
Instance Method Details
#start(addr, port) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/roma/tools/test-scenario.rb', line 45 def start addr, port Thread.new { sleep_time=10 while @runnable sleep sleep_time printf("qps=%d max=%f min=%f ave=%f\n", @cnt / sleep_time, @tmax, @tmin, sleep_time / @cnt.to_f) @@cnt=0 @@tmax=0 @@tmin=100 end } working_threads = [] @num_of_threads.times { working_threads << Thread.new { send_random_reqs addr, port } } end |