Class: TestProf::FactoryProf::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/test_prof/factory_prof.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stacks, raw_stats) ⇒ Result

Returns a new instance of Result.



54
55
56
57
# File 'lib/test_prof/factory_prof.rb', line 54

def initialize(stacks, raw_stats)
  @stacks = stacks
  @raw_stats = raw_stats
end

Instance Attribute Details

#raw_statsObject (readonly)

Returns the value of attribute raw_stats.



52
53
54
# File 'lib/test_prof/factory_prof.rb', line 52

def raw_stats
  @raw_stats
end

#stacksObject (readonly)

Returns the value of attribute stacks.



52
53
54
# File 'lib/test_prof/factory_prof.rb', line 52

def stacks
  @stacks
end

Instance Method Details

#statsObject

Returns sorted stats



60
61
62
63
64
65
66
67
68
69
# File 'lib/test_prof/factory_prof.rb', line 60

def stats
  @stats ||= @raw_stats.values.sort_by { |el| -el[:total_count] }.map do |stat|
    unless stat[:variations].empty?
      stat = stat.dup
      stat[:variations] = stat[:variations].values.sort_by { |nested_el| -nested_el[:total_count] }
    end

    stat
  end
end

#total_countObject



71
72
73
# File 'lib/test_prof/factory_prof.rb', line 71

def total_count
  @total_count ||= @raw_stats.values.sum { |v| v[:total_count] }
end

#total_timeObject



75
76
77
# File 'lib/test_prof/factory_prof.rb', line 75

def total_time
  @total_time ||= @raw_stats.values.sum { |v| v[:total_time] }
end