Class: Rack::Bug::SphinxPanel::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/bug/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.



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

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

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



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

#timeObject



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