Class: Rack::Insight::SphinxPanel::Stats
- Inherits:
-
Object
- Object
- Rack::Insight::SphinxPanel::Stats
- Defined in:
- lib/rack/insight/panels/sphinx_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_args, method_call) ⇒ Object
- #time ⇒ Object
Constructor Details
#initialize ⇒ Stats
Returns a new instance of Stats.
174 175 176 177 178 |
# File 'lib/rack/insight/panels/sphinx_panel/stats.rb', line 174 def initialize @queries = [] @calls = 0 @time = 0.0 end |
Instance Attribute Details
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
171 172 173 |
# File 'lib/rack/insight/panels/sphinx_panel/stats.rb', line 171 def calls @calls end |
#queries ⇒ Object (readonly)
Returns the value of attribute queries.
172 173 174 |
# File 'lib/rack/insight/panels/sphinx_panel/stats.rb', line 172 def queries @queries end |
Instance Method Details
#display_time ⇒ Object
186 187 188 |
# File 'lib/rack/insight/panels/sphinx_panel/stats.rb', line 186 def display_time "%.2fms" % time end |
#record_call(time, command_args, method_call) ⇒ Object
180 181 182 183 184 |
# File 'lib/rack/insight/panels/sphinx_panel/stats.rb', line 180 def record_call(time, command_args, method_call) @queries << Query.new(time, command_args, method_call) @calls += 1 @time += time end |
#time ⇒ Object
190 191 192 193 194 |
# File 'lib/rack/insight/panels/sphinx_panel/stats.rb', line 190 def time @queries.inject(0) do |memo, query| memo + query.time end end |