Class: Mysql2::Client
- Inherits:
-
Object
- Object
- Mysql2::Client
- Defined in:
- lib/peek/views/mysql2.rb
Overview
Instrument SQL time
Class Attribute Summary collapse
-
.query_count ⇒ Object
Returns the value of attribute query_count.
-
.query_time ⇒ Object
Returns the value of attribute query_time.
Instance Method Summary collapse
Class Attribute Details
.query_count ⇒ Object
Returns the value of attribute query_count.
7 8 9 |
# File 'lib/peek/views/mysql2.rb', line 7 def query_count @query_count end |
.query_time ⇒ Object
Returns the value of attribute query_time.
7 8 9 |
# File 'lib/peek/views/mysql2.rb', line 7 def query_time @query_time end |
Instance Method Details
#query_with_timing(*args) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/peek/views/mysql2.rb', line 12 def query_with_timing(*args) start = Time.now query_without_timing(*args) ensure duration = (Time.now - start) Mysql2::Client.query_time.update { |value| value + duration } Mysql2::Client.query_count.update { |value| value + 1 } end |