Class: PG::Connection
- Inherits:
-
Object
- Object
- PG::Connection
- Defined in:
- lib/peek/views/pg.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/pg.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/pg.rb', line 7 def query_time @query_time end |
Instance Method Details
#async_exec_with_timing(*args) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/peek/views/pg.rb', line 22 def async_exec_with_timing(*args) start = Time.now async_exec_without_timing(*args) ensure duration = (Time.now - start) PG::Connection.query_time.update { |value| value + duration } PG::Connection.query_count.update { |value| value + 1 } end |
#exec_with_timing(*args) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/peek/views/pg.rb', line 12 def exec_with_timing(*args) start = Time.now exec_without_timing(*args) ensure duration = (Time.now - start) PG::Connection.query_time.update { |value| value + duration } PG::Connection.query_count.update { |value| value + 1 } end |