Class: TimingTest

Inherits:
Object
  • Object
show all
Defined in:
lib/load/timing_test.rb

Direct Known Subclasses

CpuMonitor, FileIoMonitor, NetworkMonitor, RamMonitor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTimingTest

Returns a new instance of TimingTest.



8
9
10
11
12
13
14
# File 'lib/load/timing_test.rb', line 8

def initialize
  @params = {}
  @index = 0
  @owner = nil
  @test_code = nil
  @target_code = nil
end

Instance Attribute Details

#indexObject

Returns the value of attribute index.



6
7
8
# File 'lib/load/timing_test.rb', line 6

def index
  @index
end

#loggerObject

Returns the value of attribute logger.



6
7
8
# File 'lib/load/timing_test.rb', line 6

def logger
  @logger
end

#ownerObject

Returns the value of attribute owner.



6
7
8
# File 'lib/load/timing_test.rb', line 6

def owner
  @owner
end

#paramsObject

Returns the value of attribute params.



6
7
8
# File 'lib/load/timing_test.rb', line 6

def params
  @params
end

#target_codeObject

Returns the value of attribute target_code.



6
7
8
# File 'lib/load/timing_test.rb', line 6

def target_code
  @target_code
end

#test_codeObject

Returns the value of attribute test_code.



6
7
8
# File 'lib/load/timing_test.rb', line 6

def test_code
  @test_code
end

Instance Method Details

#assert(value) ⇒ Object



59
60
61
62
63
64
# File 'lib/load/timing_test.rb', line 59

def assert(value)
  if (value == false)
    puts "Assertion failed"
    raise "Assertion failed"
  end
end

#ellaped_millisObject



34
35
36
# File 'lib/load/timing_test.rb', line 34

def ellaped_millis
  @owner.time_ellapsed_millis
end

#logObject



38
39
40
# File 'lib/load/timing_test.rb', line 38

def log
  return @logger
end

#pause_after_runObject



66
67
68
# File 'lib/load/timing_test.rb', line 66

def pause_after_run
  # Default is no pause
end

#runObject



22
23
24
# File 'lib/load/timing_test.rb', line 22

def run
  raise "Not Implemented"
end

#server_urlObject



26
27
28
29
30
31
32
# File 'lib/load/timing_test.rb', line 26

def server_url
  url = LoadNode.instance.target_server
  if (url == nil)
    raise "target_server not specified when starting main process"
  end
  return url
end

#set_upObject



16
17
# File 'lib/load/timing_test.rb', line 16

def set_up
end

#tear_downObject



19
20
# File 'lib/load/timing_test.rb', line 19

def tear_down
end

#time_block(code) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/load/timing_test.rb', line 42

def time_block(code)
  start_time = Time.now
  begin
    yield
    end_time = Time.now
    block_time = (end_time.to_f - start_time.to_f) * 1000
    @owner.report_block_result(code, @index, @owner.time_ellapsed_millis, block_time, LoadTest::PASSED, target_code)
  rescue Exception => e
    log.error("Exception running timing block (#{code}) test: #{e.message}")
    end_time = Time.now
    block_time = (end_time.to_f - start_time.to_f) * 1000
    @owner.report_block_result(code, @index, @owner.time_ellapsed_millis, block_time, LoadTest::FAILED, target_code)
    raise e
  end
end

#timingObject



70
71
72
73
# File 'lib/load/timing_test.rb', line 70

def timing
  # LoadTest times the run method and uses that timing unless the instance of TimingTest timing method returns a non-nil time.
  return nil
end