Class: LoadTest::Stat
- Inherits:
-
Object
- Object
- LoadTest::Stat
- Includes:
- Enumerable
- Defined in:
- lib/load_test/stat.rb
Overview
Statistics are taken from the load test results.
Class Method Summary collapse
-
.load(result) ⇒ Object
:nodoc:.
-
.start(&block) ⇒ Object
Constructor of LoadTest::Stat.
Instance Method Summary collapse
-
#add(hash1 = nil, **hash2) ⇒ Object
Enter data for aggregation.
-
#each ⇒ Object
Repeat LoadTest::StatRow.
-
#finish ⇒ Object
This method performs data relocation.
-
#initialize ⇒ Stat
constructor
:nodoc:.
Constructor Details
Class Method Details
.load(result) ⇒ Object
:nodoc:
5 6 7 8 9 10 11 12 |
# File 'lib/load_test/stat.rb', line 5 def self.load(result) # :nodoc: this = new result.each do this.add(_1) end this.finish this end |
.start(&block) ⇒ Object
Constructor of LoadTest::Stat
- block {|stat| … }
-
Data entry within the block. The argument is LoadTest::Stat.
- return
-
LoadTest::Stat
18 19 20 21 22 23 |
# File 'lib/load_test/stat.rb', line 18 def self.start(&block) this = new block.call this this.finish this end |
Instance Method Details
#add(hash1 = nil, **hash2) ⇒ Object
Enter data for aggregation.
hash1 and hash2 are the same.
{
name: Aggregate field name,
value: The value you want to stat, such as speed,
error: If you get an error,
}
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/load_test/stat.rb', line 38 def add(hash1 = nil, **hash2) hash = hash1 || hash2 if hash.key?(:value) @rows[hash[:name]].values << hash[:value] end if hash.key?(:error) @rows[hash[:name]].errors << hash[:error] end end |
#each ⇒ Object
Repeat LoadTest::StatRow.
58 59 60 |
# File 'lib/load_test/stat.rb', line 58 def each(...) @rows.values.each(...) end |
#finish ⇒ Object
This method performs data relocation. Call when you have finished entering data. If you are using LoadTest::Stat.start or LoadTest::Stat.load, it will be done automatically.
53 54 55 |
# File 'lib/load_test/stat.rb', line 53 def finish @rows.values.each(&:finish) end |