Class: LoadTest::StatRow

Inherits:
Object
  • Object
show all
Defined in:
lib/load_test/stat_row.rb

Overview

Statistics

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ StatRow

Constructor



11
12
13
14
15
# File 'lib/load_test/stat_row.rb', line 11

def initialize(name)
  @name = name
  @values = []
  @errors = []
end

Instance Attribute Details

#errorsObject

An array of errors.



8
9
10
# File 'lib/load_test/stat_row.rb', line 8

def errors
  @errors
end

#nameObject

name



4
5
6
# File 'lib/load_test/stat_row.rb', line 4

def name
  @name
end

#valuesObject

Data array for statistics.



6
7
8
# File 'lib/load_test/stat_row.rb', line 6

def values
  @values
end

Instance Method Details

#averageObject

Calculate the average value.



24
25
26
# File 'lib/load_test/stat_row.rb', line 24

def average
  @values.sum / @values.size.to_f
end

#countObject

Number of data used for statistics.



40
41
42
# File 'lib/load_test/stat_row.rb', line 40

def count
  @values.size
end

#error_countObject

number of errors.



45
46
47
# File 'lib/load_test/stat_row.rb', line 45

def error_count
  @errors.size
end

#finishObject

This method performs data relocation. Call when you have finished entering data.



19
20
21
# File 'lib/load_test/stat_row.rb', line 19

def finish
  @values.sort!
end

#medianObject

Calculate the median value.



35
36
37
# File 'lib/load_test/stat_row.rb', line 35

def median
  percentile(50)
end

#percentile(value) ⇒ Object

Calculate the percentile value.



29
30
31
32
# File 'lib/load_test/stat_row.rb', line 29

def percentile(value)
  index = (@values.size.pred * value / 100.0).round
  @values[index]
end