Class: Rack::Insight::SphinxPanel::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/insight/panels/sphinx_panel/stats.rb

Defined Under Namespace

Classes: Query

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStats

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

#callsObject (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

#queriesObject (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_timeObject



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

#timeObject



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