Class: Innodb::Stats
- Inherits:
-
Object
- Object
- Innodb::Stats
- Defined in:
- lib/innodb/stats.rb
Overview
Collect stats globally within innodb_ruby for comparison purposes and for correctness checking.
Constant Summary collapse
- @@data =
Hash.new(0)
Class Method Summary collapse
-
.data ⇒ Object
Return the data hash directly.
-
.get(name) ⇒ Object
Get a statistic by name.
-
.increment(name, value = 1) ⇒ Object
Increment a statistic by name (typically a symbol), optionally by a value provided.
-
.print_report(io = STDOUT) ⇒ Object
Print a simple report of collected statistics, optionally to the IO object provided, or by default to STDOUT.
-
.reset ⇒ Object
Reset all statistics.
Class Method Details
.data ⇒ Object
Return the data hash directly.
9 10 11 |
# File 'lib/innodb/stats.rb', line 9 def self.data @@data end |
.get(name) ⇒ Object
Get a statistic by name.
20 21 22 |
# File 'lib/innodb/stats.rb', line 20 def self.get(name) @@data[name] end |
.increment(name, value = 1) ⇒ Object
Increment a statistic by name (typically a symbol), optionally by a value provided.
15 16 17 |
# File 'lib/innodb/stats.rb', line 15 def self.increment(name, value=1) @@data[name] += value end |
.print_report(io = STDOUT) ⇒ Object
Print a simple report of collected statistics, optionally to the IO object provided, or by default to STDOUT.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/innodb/stats.rb', line 32 def self.print_report(io=STDOUT) io.puts "%-50s%10s" % [ "Statistic", "Count", ] @@data.sort.each do |name, count| io.puts "%-50s%10i" % [ name, count ] end nil end |
.reset ⇒ Object
Reset all statistics.
25 26 27 28 |
# File 'lib/innodb/stats.rb', line 25 def self.reset @@data.clear nil end |