Class: FactoryBotProfile::FactoryStat
- Inherits:
-
Stat
- Object
- Stat
- FactoryBotProfile::FactoryStat
show all
- Defined in:
- lib/factory_bot_profile/stat.rb
Instance Attribute Summary collapse
Attributes inherited from Stat
#count, #name, #total_time
Instance Method Summary
collapse
Methods inherited from Stat
#average_time
Constructor Details
Returns a new instance of FactoryStat.
33
34
35
36
|
# File 'lib/factory_bot_profile/stat.rb', line 33
def initialize(name)
super
@child_stats = child_stats_hash
end
|
Instance Attribute Details
#child_stats ⇒ Object
Returns the value of attribute child_stats.
31
32
33
|
# File 'lib/factory_bot_profile/stat.rb', line 31
def child_stats
@child_stats
end
|
Instance Method Details
#child_stats_by_average_time ⇒ Object
59
60
61
|
# File 'lib/factory_bot_profile/stat.rb', line 59
def child_stats_by_average_time
child_stats.values.sort_by(&:average_time)
end
|
#child_stats_by_total_time ⇒ Object
55
56
57
|
# File 'lib/factory_bot_profile/stat.rb', line 55
def child_stats_by_total_time
child_stats.values.sort_by(&:total_time)
end
|
#increment(frame) ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/factory_bot_profile/stat.rb', line 38
def increment(frame)
@count += 1
@total_time += frame.duration
frame.child_time.each do |name, time|
@child_stats[name].increment(time)
end
end
|
#marshal_dump ⇒ Object
71
72
73
|
# File 'lib/factory_bot_profile/stat.rb', line 71
def marshal_dump
[@name, @count, @total_time, Hash[@child_stats]]
end
|
#marshal_load(data) ⇒ Object
75
76
77
78
|
# File 'lib/factory_bot_profile/stat.rb', line 75
def marshal_load(data)
@name, @count, @total_time, child_stats = data
@child_stats = child_stats_hash.merge!(child_stats)
end
|
#merge!(other) ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/factory_bot_profile/stat.rb', line 63
def merge!(other)
super
other.child_stats.each do |name, stat|
@child_stats[name].merge!(stat)
end
end
|
#total_child_time ⇒ Object
51
52
53
|
# File 'lib/factory_bot_profile/stat.rb', line 51
def total_child_time
child_stats.values.map(&:total_time).sum
end
|
#total_self_time ⇒ Object
47
48
49
|
# File 'lib/factory_bot_profile/stat.rb', line 47
def total_self_time
total_time - total_child_time
end
|