Class: Lavin::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/lavin/stats.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(duration:, total_requests:, rate:, requests: [], step_summary: {}, steps: [], failures: []) ⇒ Stats

Returns a new instance of Stats.



7
8
9
10
11
12
13
14
15
# File 'lib/lavin/stats.rb', line 7

def initialize(duration:, total_requests:, rate:, requests: [], step_summary: {}, steps: [], failures: [])
  @duration = duration
  @total_requests = total_requests
  @rate = rate
  @requests = requests
  @step_summary = step_summary
  @steps = steps
  @failures = failures
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



5
6
7
# File 'lib/lavin/stats.rb', line 5

def duration
  @duration
end

#failuresObject (readonly)

Returns the value of attribute failures.



5
6
7
# File 'lib/lavin/stats.rb', line 5

def failures
  @failures
end

#rateObject (readonly)

Returns the value of attribute rate.



5
6
7
# File 'lib/lavin/stats.rb', line 5

def rate
  @rate
end

#requestsObject (readonly)

Returns the value of attribute requests.



5
6
7
# File 'lib/lavin/stats.rb', line 5

def requests
  @requests
end

#step_summaryObject (readonly)

Returns the value of attribute step_summary.



5
6
7
# File 'lib/lavin/stats.rb', line 5

def step_summary
  @step_summary
end

#stepsObject (readonly)

Returns the value of attribute steps.



5
6
7
# File 'lib/lavin/stats.rb', line 5

def steps
  @steps
end

#total_requestsObject (readonly)

Returns the value of attribute total_requests.



5
6
7
# File 'lib/lavin/stats.rb', line 5

def total_requests
  @total_requests
end

Instance Method Details

#each_failure(&block) ⇒ Object



53
54
55
# File 'lib/lavin/stats.rb', line 53

def each_failure(&block)
  failures.each(&block)
end

#each_request(&block) ⇒ Object



49
50
51
# File 'lib/lavin/stats.rb', line 49

def each_request(&block)
  requests.each(&block)
end

#each_step(&block) ⇒ Object



45
46
47
# File 'lib/lavin/stats.rb', line 45

def each_step(&block)
  steps.each(&block)
end

#empty?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/lavin/stats.rb', line 17

def empty?
  requests.empty?
end

#failed_stepsObject



41
42
43
# File 'lib/lavin/stats.rb', line 41

def failed_steps
  @step_summary[:failure]
end

#successful_stepsObject



37
38
39
# File 'lib/lavin/stats.rb', line 37

def successful_steps
  @step_summary[:success]
end

#to_hObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/lavin/stats.rb', line 21

def to_h
  {
    duration:,
    total_requests:,
    rate:,
    requests:,
    step_summary:,
    steps:,
    failures:
  }
end

#total_stepsObject



33
34
35
# File 'lib/lavin/stats.rb', line 33

def total_steps
  @step_summary[:count]
end