class TimingTest

Attributes

index[RW]
logger[RW]
owner[RW]
params[RW]
target_code[RW]
test_code[RW]

Public Class Methods

new() click to toggle source
# File lib/load/timing_test.rb, line 8
def initialize
  @params = {}
  @index = 0
  @owner = nil
  @test_code = nil
  @target_code = nil
end

Public Instance Methods

assert(value) click to toggle source
# File lib/load/timing_test.rb, line 59
def assert(value)
  if (value == false)
    puts "Assertion failed"
    raise "Assertion failed"
  end
end
ellaped_millis() click to toggle source
# File lib/load/timing_test.rb, line 34
def ellaped_millis
  @owner.time_ellapsed_millis
end
log() click to toggle source
# File lib/load/timing_test.rb, line 38
def log
  return @logger
end
pause_after_run() click to toggle source
# File lib/load/timing_test.rb, line 66
def pause_after_run
  # Default is no pause
end
run() click to toggle source
# File lib/load/timing_test.rb, line 22
def run
  raise "Not Implemented"
end
server_url() click to toggle source
# 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_up() click to toggle source
# File lib/load/timing_test.rb, line 16
def set_up
end
tear_down() click to toggle source
# File lib/load/timing_test.rb, line 19
def tear_down
end
time_block(code) { || ... } click to toggle source
# 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
timing() click to toggle source
# 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