Class: DeepTest::Distributed::ThroughputRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/deep_test/distributed/throughput_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(options, test_count, blackboard = nil, &block) ⇒ ThroughputRunner

Returns a new instance of ThroughputRunner.



4
5
6
7
8
9
# File 'lib/deep_test/distributed/throughput_runner.rb', line 4

def initialize(options, test_count, blackboard = nil, &block)
  @options = options
  @test_count = test_count
  @blackboard = blackboard
  @progress_block = block
end

Instance Method Details

#blackboardObject



11
12
13
# File 'lib/deep_test/distributed/throughput_runner.rb', line 11

def blackboard
  @blackboard ||= @options.server
end

#process_work_unitsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/deep_test/distributed/throughput_runner.rb', line 19

def process_work_units
  @start_time = Time.now

  @test_count.times do
    blackboard.write_work NullWorkUnit.new
  end
 
  results_read = 0
  until results_read == @test_count
    Thread.pass
    result = blackboard.take_result
    if result
      results_read += 1 
      @progress_block.call(result) if @progress_block
    end
  end

  @end_time = Time.now

  true
end

#statisticsObject



15
16
17
# File 'lib/deep_test/distributed/throughput_runner.rb', line 15

def statistics
  ThroughputStatistics.new(@test_count, @start_time, @end_time)
end