Class: MongoProfiler::ProfileGroup
- Inherits:
-
Object
- Object
- MongoProfiler::ProfileGroup
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/mongo_profiler/models/profile_group.rb
Instance Method Summary collapse
- #avg_time ⇒ Object
- #count_by_score(score) ⇒ Object
- #filter_by_score(score) ⇒ Object
- #max_time ⇒ Object
- #min_time ⇒ Object
- #total_time ⇒ Object
Instance Method Details
#avg_time ⇒ Object
16 17 18 19 |
# File 'lib/mongo_profiler/models/profile_group.rb', line 16 def avg_time return 0 if (count = profiles.count) == 0 total_time / count end |
#count_by_score(score) ⇒ Object
35 36 37 |
# File 'lib/mongo_profiler/models/profile_group.rb', line 35 def count_by_score(score) filter_by_score(score).size end |
#filter_by_score(score) ⇒ Object
29 30 31 32 33 |
# File 'lib/mongo_profiler/models/profile_group.rb', line 29 def filter_by_score(score) profiles.select do |p| p.score == score end end |
#max_time ⇒ Object
25 26 27 |
# File 'lib/mongo_profiler/models/profile_group.rb', line 25 def max_time profiles.collect(&:total_time).max end |
#min_time ⇒ Object
21 22 23 |
# File 'lib/mongo_profiler/models/profile_group.rb', line 21 def min_time profiles.collect(&:total_time).min end |
#total_time ⇒ Object
12 13 14 |
# File 'lib/mongo_profiler/models/profile_group.rb', line 12 def total_time profiles.sum(&:total_time) end |