Sha256: 59c24bdd4eb12f68e5393facbac33f2ade714dcae6f45e6b562ee74cf4f38b6f
Contents?: true
Size: 1.75 KB
Versions: 3
Compression:
Stored size: 1.75 KB
Contents
# Stats that are associated with each instrumented method. class ScoutRails::MetricStats attr_accessor :call_count attr_accessor :min_call_time attr_accessor :max_call_time attr_accessor :total_call_time attr_accessor :total_exclusive_time attr_accessor :sum_of_squares def initialize self.call_count = 0 self.total_call_time = 0.0 self.total_exclusive_time = 0.0 self.min_call_time = 0.0 self.max_call_time = 0.0 self.sum_of_squares = 0.0 end def update!(call_time,exclusive_time) self.min_call_time = call_time if self.call_count == 0 or call_time < min_call_time self.max_call_time = call_time if self.call_count == 0 or call_time > max_call_time self.call_count +=1 self.total_call_time += call_time self.total_exclusive_time += exclusive_time self.sum_of_squares += (call_time * call_time) self end # combines data from another MetricStats object def combine!(other) self.call_count += other.call_count self.total_call_time += other.total_call_time self.total_exclusive_time += other.total_exclusive_time self.min_call_time = other.min_call_time if other.min_call_time < self.min_call_time self.max_call_time = other.max_call_time if other.max_call_time > self.max_call_time self.sum_of_squares += other.sum_of_squares self end # To avoid conflicts with different JSON libaries handle JSON ourselves. # Time-based metrics are converted to milliseconds from seconds. def to_json(*a) %Q[{"total_exclusive_time":#{total_exclusive_time*1000},"min_call_time":#{min_call_time*1000},"call_count":#{call_count},"sum_of_squares":#{sum_of_squares*1000},"total_call_time":#{total_call_time*1000},"max_call_time":#{max_call_time*1000}}] end end # class MetricStats
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
scout_rails-0.0.3.pre | lib/scout_rails/metric_stats.rb |
scout_rails-0.0.2 | lib/scout_rails/metric_stats.rb |
scout_rails-0.0.1 | lib/scout_rails/metric_stats.rb |