Class: MongoProfiler::ProfileGroup

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/mongo_profiler/models/profile_group.rb

Instance Method Summary collapse

Instance Method Details

#avg_timeObject



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_timeObject



25
26
27
# File 'lib/mongo_profiler/models/profile_group.rb', line 25

def max_time
  profiles.collect(&:total_time).max
end

#min_timeObject



21
22
23
# File 'lib/mongo_profiler/models/profile_group.rb', line 21

def min_time
  profiles.collect(&:total_time).min
end

#total_timeObject



12
13
14
# File 'lib/mongo_profiler/models/profile_group.rb', line 12

def total_time
  profiles.sum(&:total_time)
end