Class: SqlReporter::Total
- Inherits:
-
Object
- Object
- SqlReporter::Total
- Defined in:
- lib/sql_reporter/total.rb
Instance Attribute Summary collapse
-
#cached_query_diff ⇒ Object
Returns the value of attribute cached_query_diff.
-
#duration_diff ⇒ Object
Returns the value of attribute duration_diff.
-
#query_diff ⇒ Object
Returns the value of attribute query_diff.
Instance Method Summary collapse
- #+(total) ⇒ Object
- #duration_msg ⇒ Object
-
#initialize(query, duration, cached) ⇒ Total
constructor
A new instance of Total.
- #queries_msg ⇒ Object
- #query_drop ⇒ Object
- #query_gain ⇒ Object
- #summary ⇒ Object
Constructor Details
#initialize(query, duration, cached) ⇒ Total
Returns a new instance of Total.
6 7 8 9 10 |
# File 'lib/sql_reporter/total.rb', line 6 def initialize @query_diff = 0 @duration_diff = 0 @cached_query_diff = 0 end |
Instance Attribute Details
#cached_query_diff ⇒ Object
Returns the value of attribute cached_query_diff.
5 6 7 |
# File 'lib/sql_reporter/total.rb', line 5 def cached_query_diff @cached_query_diff end |
#duration_diff ⇒ Object
Returns the value of attribute duration_diff.
5 6 7 |
# File 'lib/sql_reporter/total.rb', line 5 def duration_diff @duration_diff end |
#query_diff ⇒ Object
Returns the value of attribute query_diff.
5 6 7 |
# File 'lib/sql_reporter/total.rb', line 5 def query_diff @query_diff end |
Instance Method Details
#+(total) ⇒ Object
38 39 40 |
# File 'lib/sql_reporter/total.rb', line 38 def +(total) self.class.new(query_diff + total.query_diff, duration_diff + total.duration_diff, cached_query_diff + total.cached_query_diff) end |
#duration_msg ⇒ Object
30 31 32 |
# File 'lib/sql_reporter/total.rb', line 30 def duration_msg "\nDuration #{duration_diff > 0 ? 'gain' : 'decrease' }[ms]: #{duration_diff.abs.round(2)}\n" end |
#queries_msg ⇒ Object
26 27 28 |
# File 'lib/sql_reporter/total.rb', line 26 def queries_msg "\nQueries count change: #{query_diff}\n" end |
#query_drop ⇒ Object
22 23 24 |
# File 'lib/sql_reporter/total.rb', line 22 def query_drop query_diff > 0 ? 0 : -query_diff end |
#query_gain ⇒ Object
18 19 20 |
# File 'lib/sql_reporter/total.rb', line 18 def query_gain query_diff > 0 ? query_diff : 0 end |
#summary ⇒ Object
34 35 36 |
# File 'lib/sql_reporter/total.rb', line 34 def summary queries_msg + duration_msg + "\n" end |