Class: MysqlDumpSlow::Counter
- Inherits:
-
Object
- Object
- MysqlDumpSlow::Counter
- Defined in:
- lib/mysql_dump_slow/counter.rb
Instance Attribute Summary collapse
-
#abstract_query ⇒ Object
readonly
Returns the value of attribute abstract_query.
-
#total_count ⇒ Object
readonly
Returns the value of attribute total_count.
-
#total_lock_time ⇒ Object
readonly
Returns the value of attribute total_lock_time.
-
#total_query_time ⇒ Object
readonly
Returns the value of attribute total_query_time.
-
#total_rows_sent ⇒ Object
readonly
Returns the value of attribute total_rows_sent.
-
#user_hosts ⇒ Object
readonly
Returns the value of attribute user_hosts.
Instance Method Summary collapse
- #average_lock_time ⇒ Object
- #average_query_time ⇒ Object
- #average_rows_sent ⇒ Object
- #count_up(log) ⇒ Object
-
#initialize(abstract_query) ⇒ Counter
constructor
A new instance of Counter.
- #to_mysqldumpslow ⇒ Object
- #total_user_host ⇒ Object
Constructor Details
#initialize(abstract_query) ⇒ Counter
Returns a new instance of Counter.
5 6 7 |
# File 'lib/mysql_dump_slow/counter.rb', line 5 def initialize(abstract_query) @abstract_query = abstract_query end |
Instance Attribute Details
#abstract_query ⇒ Object (readonly)
Returns the value of attribute abstract_query.
3 4 5 |
# File 'lib/mysql_dump_slow/counter.rb', line 3 def abstract_query @abstract_query end |
#total_count ⇒ Object (readonly)
Returns the value of attribute total_count.
3 4 5 |
# File 'lib/mysql_dump_slow/counter.rb', line 3 def total_count @total_count end |
#total_lock_time ⇒ Object (readonly)
Returns the value of attribute total_lock_time.
3 4 5 |
# File 'lib/mysql_dump_slow/counter.rb', line 3 def total_lock_time @total_lock_time end |
#total_query_time ⇒ Object (readonly)
Returns the value of attribute total_query_time.
3 4 5 |
# File 'lib/mysql_dump_slow/counter.rb', line 3 def total_query_time @total_query_time end |
#total_rows_sent ⇒ Object (readonly)
Returns the value of attribute total_rows_sent.
3 4 5 |
# File 'lib/mysql_dump_slow/counter.rb', line 3 def total_rows_sent @total_rows_sent end |
#user_hosts ⇒ Object (readonly)
Returns the value of attribute user_hosts.
3 4 5 |
# File 'lib/mysql_dump_slow/counter.rb', line 3 def user_hosts @user_hosts end |
Instance Method Details
#average_lock_time ⇒ Object
25 26 27 |
# File 'lib/mysql_dump_slow/counter.rb', line 25 def average_lock_time total_lock_time / total_count end |
#average_query_time ⇒ Object
21 22 23 |
# File 'lib/mysql_dump_slow/counter.rb', line 21 def average_query_time total_query_time / total_count end |
#average_rows_sent ⇒ Object
29 30 31 |
# File 'lib/mysql_dump_slow/counter.rb', line 29 def average_rows_sent total_rows_sent / total_count end |
#count_up(log) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/mysql_dump_slow/counter.rb', line 9 def count_up(log) count_up_query_time(log.query_time) count_up_lock_time(log.lock_time) count_up_rows_sent(log.rows_sent) count_up_user_host(log.user_host) count_up_counter end |
#to_mysqldumpslow ⇒ Object
33 34 35 36 37 38 |
# File 'lib/mysql_dump_slow/counter.rb', line 33 def to_mysqldumpslow <<-EOS Count: #{total_count} Time=#{average_query_time/1000}s (#{total_query_time/1000}s) Lock=#{average_lock_time/1000}s (#{total_lock_time/1000}s) Rows=#{average_rows_sent} (#{total_rows_sent}), #{ user_hosts.size == 1 ? user_hosts.first : user_hosts.size.to_s + 'hosts'} #{abstract_query} EOS end |
#total_user_host ⇒ Object
17 18 19 |
# File 'lib/mysql_dump_slow/counter.rb', line 17 def total_user_host @user_hosts.size end |