Class: ActiveRecordQueryCounter::TransactionInfo
- Inherits:
-
Object
- Object
- ActiveRecordQueryCounter::TransactionInfo
- Defined in:
- lib/active_record_query_counter/transaction_info.rb
Overview
Data structure for storing the counts and timings of a transaction. Note that the start and end times are monotonic time and not wall clock time.
This structure deliberately does not hold the queries executed within the transaction so
that retaining it for the duration of a count_queries block stays cheap. The full query
details are only available transiently in the transaction_time notification payload
(see TransactionDetails).
Instance Attribute Summary collapse
-
#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.
-
#idle_time ⇒ Object
readonly
Returns the value of attribute idle_time.
-
#query_count ⇒ Object
readonly
Returns the value of attribute query_count.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#trace ⇒ Object
readonly
Returns the value of attribute trace.
Instance Method Summary collapse
-
#elapsed_time ⇒ Float
Return the time spent in the transaction.
-
#initialize(start_time:, end_time:, trace:, query_count: 0, gc_time: 0.0, cpu_time: 0.0, idle_time: 0.0) ⇒ TransactionInfo
constructor
A new instance of TransactionInfo.
Constructor Details
#initialize(start_time:, end_time:, trace:, query_count: 0, gc_time: 0.0, cpu_time: 0.0, idle_time: 0.0) ⇒ TransactionInfo
Returns a new instance of TransactionInfo.
14 15 16 17 18 19 20 21 22 |
# File 'lib/active_record_query_counter/transaction_info.rb', line 14 def initialize(start_time:, end_time:, trace:, query_count: 0, gc_time: 0.0, cpu_time: 0.0, idle_time: 0.0) @start_time = start_time @end_time = end_time @trace = trace @query_count = query_count @gc_time = gc_time @cpu_time = cpu_time @idle_time = idle_time end |
Instance Attribute Details
#cpu_time ⇒ Object (readonly)
Returns the value of attribute cpu_time.
12 13 14 |
# File 'lib/active_record_query_counter/transaction_info.rb', line 12 def cpu_time @cpu_time end |
#end_time ⇒ Object (readonly)
Returns the value of attribute end_time.
12 13 14 |
# File 'lib/active_record_query_counter/transaction_info.rb', line 12 def end_time @end_time end |
#gc_time ⇒ Object (readonly)
Returns the value of attribute gc_time.
12 13 14 |
# File 'lib/active_record_query_counter/transaction_info.rb', line 12 def gc_time @gc_time end |
#idle_time ⇒ Object (readonly)
Returns the value of attribute idle_time.
12 13 14 |
# File 'lib/active_record_query_counter/transaction_info.rb', line 12 def idle_time @idle_time end |
#query_count ⇒ Object (readonly)
Returns the value of attribute query_count.
12 13 14 |
# File 'lib/active_record_query_counter/transaction_info.rb', line 12 def query_count @query_count end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
12 13 14 |
# File 'lib/active_record_query_counter/transaction_info.rb', line 12 def start_time @start_time end |
#trace ⇒ Object (readonly)
Returns the value of attribute trace.
12 13 14 |
# File 'lib/active_record_query_counter/transaction_info.rb', line 12 def trace @trace end |
Instance Method Details
#elapsed_time ⇒ Float
Return the time spent in the transaction.
27 28 29 |
# File 'lib/active_record_query_counter/transaction_info.rb', line 27 def elapsed_time end_time - start_time end |