Class: Rack::Bug::SphinxPanel::Stats
- Inherits:
-
Object
- Object
- Rack::Bug::SphinxPanel::Stats
- Defined in:
- lib/rack/bug/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) ⇒ Object
- #time ⇒ Object
Constructor Details
#initialize ⇒ Stats
Returns a new instance of Stats.
70 71 72 73 74 |
# File 'lib/rack/bug/panels/sphinx_panel/stats.rb', line 70 def initialize @queries = [] @calls = 0 @time = 0.0 end |
Instance Attribute Details
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
67 68 69 |
# File 'lib/rack/bug/panels/sphinx_panel/stats.rb', line 67 def calls @calls end |
#queries ⇒ Object (readonly)
Returns the value of attribute queries.
68 69 70 |
# File 'lib/rack/bug/panels/sphinx_panel/stats.rb', line 68 def queries @queries end |
Instance Method Details
#display_time ⇒ Object
83 84 85 |
# File 'lib/rack/bug/panels/sphinx_panel/stats.rb', line 83 def display_time "%.2fms" % time end |
#record_call(time, *command_args) ⇒ Object
76 77 78 79 80 81 |
# File 'lib/rack/bug/panels/sphinx_panel/stats.rb', line 76 def record_call(time, *command_args) @queries << Query.new(time, command_args) @calls += 1 @time += time end |
#time ⇒ Object
87 88 89 90 91 |
# File 'lib/rack/bug/panels/sphinx_panel/stats.rb', line 87 def time @queries.inject(0) do |memo, query| memo + query.time end end |