Class: Rack::Insight::MongoPanel::Stats
- Inherits:
-
Object
- Object
- Rack::Insight::MongoPanel::Stats
- Defined in:
- lib/rack/insight/panels/mongo_panel/stats.rb
Defined Under Namespace
Classes: Query
Instance Attribute Summary collapse
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
-
#queries ⇒ Object
readonly
Returns the value of attribute queries.
Instance Method Summary collapse
- #display_time ⇒ Object
-
#initialize ⇒ Stats
constructor
A new instance of Stats.
- #record_call(time, command) ⇒ Object
- #time ⇒ Object
Constructor Details
#initialize ⇒ Stats
Returns a new instance of Stats.
22 23 24 25 26 |
# File 'lib/rack/insight/panels/mongo_panel/stats.rb', line 22 def initialize @queries = [] @calls = 0 @time = 0.0 end |
Instance Attribute Details
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
19 20 21 |
# File 'lib/rack/insight/panels/mongo_panel/stats.rb', line 19 def calls @calls end |
#queries ⇒ Object (readonly)
Returns the value of attribute queries.
20 21 22 |
# File 'lib/rack/insight/panels/mongo_panel/stats.rb', line 20 def queries @queries end |
Instance Method Details
#display_time ⇒ Object
34 35 36 |
# File 'lib/rack/insight/panels/mongo_panel/stats.rb', line 34 def display_time "%.2fms" % time end |
#record_call(time, command) ⇒ Object
28 29 30 31 32 |
# File 'lib/rack/insight/panels/mongo_panel/stats.rb', line 28 def record_call(time, command) @queries << Query.new(time, command) @calls += 1 @time += time end |
#time ⇒ Object
38 39 40 41 42 |
# File 'lib/rack/insight/panels/mongo_panel/stats.rb', line 38 def time @queries.inject(0) do |memo, query| memo + query.time end end |