Class: PerformanceTester::Outcome

Inherits:
Object
  • Object
show all
Defined in:
lib/performance_tester/outcome.rb

Overview

Documents the outcome of a scenario

Defined Under Namespace

Classes: Request

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(network_traffic, period, hosts, error = false) ⇒ Outcome

Returns a new instance of Outcome.



9
10
11
12
13
# File 'lib/performance_tester/outcome.rb', line 9

def initialize(network_traffic, period, hosts, error = false)
  @requests = network_traffic.map { |request| Request.new(request, hosts) }
  @period = period
  @error = error
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



7
8
9
# File 'lib/performance_tester/outcome.rb', line 7

def error
  @error
end

#periodObject (readonly)

Returns the value of attribute period.



7
8
9
# File 'lib/performance_tester/outcome.rb', line 7

def period
  @period
end

#requestsObject (readonly)

Returns the value of attribute requests.



7
8
9
# File 'lib/performance_tester/outcome.rb', line 7

def requests
  @requests
end

Instance Method Details

#finished_atObject



23
24
25
# File 'lib/performance_tester/outcome.rb', line 23

def finished_at
  period.last
end

#started_atObject



19
20
21
# File 'lib/performance_tester/outcome.rb', line 19

def started_at
  period.first
end

#success?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/performance_tester/outcome.rb', line 27

def success?
  !error
end

#to_sObject



31
32
33
# File 'lib/performance_tester/outcome.rb', line 31

def to_s
  error ? error.to_s : requests.map(&:to_s).inspect
end

#total_time_elapsedObject



15
16
17
# File 'lib/performance_tester/outcome.rb', line 15

def total_time_elapsed
  finished_at - started_at
end