Class: TestProf::RSpecDissect::Collectors::Base
- Inherits:
-
Object
- Object
- TestProf::RSpecDissect::Collectors::Base
- Defined in:
- lib/test_prof/rspec_dissect/collectors/base.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#top_count ⇒ Object
readonly
Returns the value of attribute top_count.
Instance Method Summary collapse
- #<<(data) ⇒ Object
-
#initialize(name:, top_count:) ⇒ Base
constructor
A new instance of Base.
- #populate!(data) ⇒ Object
- #print_group_result(group) ⇒ Object
- #print_name ⇒ Object
- #print_result_header ⇒ Object
- #print_results ⇒ Object
- #total_time ⇒ Object
- #total_time_message ⇒ Object
Constructor Details
#initialize(name:, top_count:) ⇒ Base
Returns a new instance of Base.
16 17 18 19 20 21 22 |
# File 'lib/test_prof/rspec_dissect/collectors/base.rb', line 16 def initialize(name:, top_count:) @name = name @top_count = top_count @results = Utils::SizedOrderedSet.new( top_count, sort_by: name ) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/test_prof/rspec_dissect/collectors/base.rb', line 14 def name @name end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
14 15 16 |
# File 'lib/test_prof/rspec_dissect/collectors/base.rb', line 14 def results @results end |
#top_count ⇒ Object (readonly)
Returns the value of attribute top_count.
14 15 16 |
# File 'lib/test_prof/rspec_dissect/collectors/base.rb', line 14 def top_count @top_count end |
Instance Method Details
#<<(data) ⇒ Object
28 29 30 |
# File 'lib/test_prof/rspec_dissect/collectors/base.rb', line 28 def <<(data) results << data end |
#populate!(data) ⇒ Object
24 25 26 |
# File 'lib/test_prof/rspec_dissect/collectors/base.rb', line 24 def populate!(data) data[name] = RSpecDissect.time_for(name) end |
#print_group_result(group) ⇒ Object
52 53 54 55 56 |
# File 'lib/test_prof/rspec_dissect/collectors/base.rb', line 52 def print_group_result(group) <<~GROUP #{group[:desc].truncate} (#{group[:loc]}) – #{group[name].duration} of #{group[:total].duration} (#{group[:count]}) GROUP end |
#print_name ⇒ Object
40 41 42 |
# File 'lib/test_prof/rspec_dissect/collectors/base.rb', line 40 def print_name name end |
#print_result_header ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/test_prof/rspec_dissect/collectors/base.rb', line 44 def print_result_header <<~MSG Top #{top_count} slowest suites (by `#{print_name}` time): MSG end |
#print_results ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/test_prof/rspec_dissect/collectors/base.rb', line 58 def print_results msgs = [print_result_header] results.each do |group| msgs << print_group_result(group) end msgs.join end |
#total_time ⇒ Object
32 33 34 |
# File 'lib/test_prof/rspec_dissect/collectors/base.rb', line 32 def total_time RSpecDissect.total_time_for(name) end |
#total_time_message ⇒ Object
36 37 38 |
# File 'lib/test_prof/rspec_dissect/collectors/base.rb', line 36 def "\nTotal `#{print_name}` time: #{total_time.duration}" end |