Class: MysqlDumpSlow::Counter
- Inherits:
-
Object
- Object
- MysqlDumpSlow::Counter
- Defined in:
- lib/mysql_dump_slow/counter.rb
Constant Summary collapse
- TIME_BASE_SEC =
Time.utc(2000, 1, 1).to_i
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.
7 8 9 |
# File 'lib/mysql_dump_slow/counter.rb', line 7 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
27 28 29 |
# File 'lib/mysql_dump_slow/counter.rb', line 27 def average_lock_time total_lock_time / total_count end |
#average_query_time ⇒ Object
23 24 25 |
# File 'lib/mysql_dump_slow/counter.rb', line 23 def average_query_time total_query_time / total_count end |
#average_rows_sent ⇒ Object
31 32 33 |
# File 'lib/mysql_dump_slow/counter.rb', line 31 def average_rows_sent total_rows_sent / total_count end |
#count_up(log) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/mysql_dump_slow/counter.rb', line 11 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
35 36 37 38 39 40 |
# File 'lib/mysql_dump_slow/counter.rb', line 35 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
19 20 21 |
# File 'lib/mysql_dump_slow/counter.rb', line 19 def total_user_host @user_hosts.size end |