Class: ActiveRecordQueryCounter::QueryInfo
- Inherits:
-
Object
- Object
- ActiveRecordQueryCounter::QueryInfo
- Defined in:
- lib/active_record_query_counter/query_info.rb
Overview
Data structure for storing information about a query executed within a transaction. Note that the start and end times are monotonic time and not wall clock time. Bind parameter values are deliberately not stored since they can contain sensitive data.
Instance Attribute Summary collapse
-
#connection_time ⇒ Object
readonly
Returns the value of attribute connection_time.
-
#cpu_time ⇒ Object
readonly
Returns the value of attribute cpu_time.
-
#end_time ⇒ Object
readonly
Returns the value of attribute end_time.
-
#gc_time ⇒ Object
readonly
Returns the value of attribute gc_time.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#row_count ⇒ Object
readonly
Returns the value of attribute row_count.
-
#sql ⇒ Object
readonly
Returns the value of attribute sql.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
Instance Method Summary collapse
-
#elapsed_time ⇒ Float
Return the wall clock time spent executing the query.
-
#initialize(sql:, name:, row_count:, start_time:, end_time:, gc_time: 0.0, cpu_time: 0.0, connection_time: 0.0) ⇒ QueryInfo
constructor
A new instance of QueryInfo.
Constructor Details
#initialize(sql:, name:, row_count:, start_time:, end_time:, gc_time: 0.0, cpu_time: 0.0, connection_time: 0.0) ⇒ QueryInfo
Returns a new instance of QueryInfo.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/active_record_query_counter/query_info.rb', line 10 def initialize(sql:, name:, row_count:, start_time:, end_time:, gc_time: 0.0, cpu_time: 0.0, connection_time: 0.0) @sql = sql @name = name @row_count = row_count @start_time = start_time @end_time = end_time @gc_time = gc_time @cpu_time = cpu_time @connection_time = connection_time end |
Instance Attribute Details
#connection_time ⇒ Object (readonly)
Returns the value of attribute connection_time.
8 9 10 |
# File 'lib/active_record_query_counter/query_info.rb', line 8 def connection_time @connection_time end |
#cpu_time ⇒ Object (readonly)
Returns the value of attribute cpu_time.
8 9 10 |
# File 'lib/active_record_query_counter/query_info.rb', line 8 def cpu_time @cpu_time end |
#end_time ⇒ Object (readonly)
Returns the value of attribute end_time.
8 9 10 |
# File 'lib/active_record_query_counter/query_info.rb', line 8 def end_time @end_time end |
#gc_time ⇒ Object (readonly)
Returns the value of attribute gc_time.
8 9 10 |
# File 'lib/active_record_query_counter/query_info.rb', line 8 def gc_time @gc_time end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/active_record_query_counter/query_info.rb', line 8 def name @name end |
#row_count ⇒ Object (readonly)
Returns the value of attribute row_count.
8 9 10 |
# File 'lib/active_record_query_counter/query_info.rb', line 8 def row_count @row_count end |
#sql ⇒ Object (readonly)
Returns the value of attribute sql.
8 9 10 |
# File 'lib/active_record_query_counter/query_info.rb', line 8 def sql @sql end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
8 9 10 |
# File 'lib/active_record_query_counter/query_info.rb', line 8 def start_time @start_time end |
Instance Method Details
#elapsed_time ⇒ Float
Return the wall clock time spent executing the query.
24 25 26 |
# File 'lib/active_record_query_counter/query_info.rb', line 24 def elapsed_time end_time - start_time end |