Class: RailsConsolePro::ProfileResult
- Inherits:
-
Object
- Object
- RailsConsolePro::ProfileResult
- Defined in:
- lib/rails_console_pro/profile_result.rb
Overview
Value object representing a profiling session summary
Defined Under Namespace
Classes: DuplicateQuery, QuerySample
Instance Attribute Summary collapse
-
#cache_hits ⇒ Object
readonly
Returns the value of attribute cache_hits.
-
#cache_misses ⇒ Object
readonly
Returns the value of attribute cache_misses.
-
#cache_writes ⇒ Object
readonly
Returns the value of attribute cache_writes.
-
#cached_query_count ⇒ Object
readonly
Returns the value of attribute cached_query_count.
-
#duplicate_queries ⇒ Object
readonly
Returns the value of attribute duplicate_queries.
-
#duration_ms ⇒ Object
readonly
Returns the value of attribute duration_ms.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#finished_at ⇒ Object
readonly
Returns the value of attribute finished_at.
-
#instantiation_count ⇒ Object
readonly
Returns the value of attribute instantiation_count.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#query_count ⇒ Object
readonly
Returns the value of attribute query_count.
-
#query_samples ⇒ Object
readonly
Returns the value of attribute query_samples.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#slow_queries ⇒ Object
readonly
Returns the value of attribute slow_queries.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
-
#total_sql_duration_ms ⇒ Object
readonly
Returns the value of attribute total_sql_duration_ms.
-
#write_query_count ⇒ Object
readonly
Returns the value of attribute write_query_count.
Instance Method Summary collapse
- #cache_activity? ⇒ Boolean
- #duplicate_queries? ⇒ Boolean
- #error? ⇒ Boolean
- #export_to_file(file_path, format: nil) ⇒ Object
-
#initialize(label:, duration_ms:, result:, error:, query_count:, cached_query_count:, write_query_count:, total_sql_duration_ms:, slow_queries:, duplicate_queries:, query_samples:, instantiation_count:, cache_hits:, cache_misses:, cache_writes:, started_at:, finished_at:) ⇒ ProfileResult
constructor
A new instance of ProfileResult.
- #label? ⇒ Boolean
- #query_samples? ⇒ Boolean
- #read_query_count ⇒ Object
- #slow_queries? ⇒ Boolean
- #to_html(style: :default) ⇒ Object
- #to_json(pretty: true) ⇒ Object
- #to_yaml ⇒ Object
Constructor Details
#initialize(label:, duration_ms:, result:, error:, query_count:, cached_query_count:, write_query_count:, total_sql_duration_ms:, slow_queries:, duplicate_queries:, query_samples:, instantiation_count:, cache_hits:, cache_misses:, cache_writes:, started_at:, finished_at:) ⇒ ProfileResult
Returns a new instance of ProfileResult.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rails_console_pro/profile_result.rb', line 41 def initialize(label:, duration_ms:, result:, error:, query_count:, cached_query_count:, write_query_count:, total_sql_duration_ms:, slow_queries:, duplicate_queries:, query_samples:, instantiation_count:, cache_hits:, cache_misses:, cache_writes:, started_at:, finished_at:) @label = label @duration_ms = duration_ms @result = result @error = error @query_count = query_count @cached_query_count = cached_query_count @write_query_count = write_query_count @total_sql_duration_ms = total_sql_duration_ms @slow_queries = Array(slow_queries) @duplicate_queries = Array(duplicate_queries) @query_samples = Array(query_samples) @instantiation_count = instantiation_count @cache_hits = cache_hits @cache_misses = cache_misses @cache_writes = cache_writes @started_at = started_at @finished_at = finished_at end |
Instance Attribute Details
#cache_hits ⇒ Object (readonly)
Returns the value of attribute cache_hits.
23 24 25 |
# File 'lib/rails_console_pro/profile_result.rb', line 23 def cache_hits @cache_hits end |
#cache_misses ⇒ Object (readonly)
Returns the value of attribute cache_misses.
23 24 25 |
# File 'lib/rails_console_pro/profile_result.rb', line 23 def cache_misses @cache_misses end |
#cache_writes ⇒ Object (readonly)
Returns the value of attribute cache_writes.
23 24 25 |
# File 'lib/rails_console_pro/profile_result.rb', line 23 def cache_writes @cache_writes end |
#cached_query_count ⇒ Object (readonly)
Returns the value of attribute cached_query_count.
23 24 25 |
# File 'lib/rails_console_pro/profile_result.rb', line 23 def cached_query_count @cached_query_count end |
#duplicate_queries ⇒ Object (readonly)
Returns the value of attribute duplicate_queries.
23 24 25 |
# File 'lib/rails_console_pro/profile_result.rb', line 23 def duplicate_queries @duplicate_queries end |
#duration_ms ⇒ Object (readonly)
Returns the value of attribute duration_ms.
23 24 25 |
# File 'lib/rails_console_pro/profile_result.rb', line 23 def duration_ms @duration_ms end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
23 24 25 |
# File 'lib/rails_console_pro/profile_result.rb', line 23 def error @error end |
#finished_at ⇒ Object (readonly)
Returns the value of attribute finished_at.
23 24 25 |
# File 'lib/rails_console_pro/profile_result.rb', line 23 def finished_at @finished_at end |
#instantiation_count ⇒ Object (readonly)
Returns the value of attribute instantiation_count.
23 24 25 |
# File 'lib/rails_console_pro/profile_result.rb', line 23 def instantiation_count @instantiation_count end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
23 24 25 |
# File 'lib/rails_console_pro/profile_result.rb', line 23 def label @label end |
#query_count ⇒ Object (readonly)
Returns the value of attribute query_count.
23 24 25 |
# File 'lib/rails_console_pro/profile_result.rb', line 23 def query_count @query_count end |
#query_samples ⇒ Object (readonly)
Returns the value of attribute query_samples.
23 24 25 |
# File 'lib/rails_console_pro/profile_result.rb', line 23 def query_samples @query_samples end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
23 24 25 |
# File 'lib/rails_console_pro/profile_result.rb', line 23 def result @result end |
#slow_queries ⇒ Object (readonly)
Returns the value of attribute slow_queries.
23 24 25 |
# File 'lib/rails_console_pro/profile_result.rb', line 23 def slow_queries @slow_queries end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
23 24 25 |
# File 'lib/rails_console_pro/profile_result.rb', line 23 def started_at @started_at end |
#total_sql_duration_ms ⇒ Object (readonly)
Returns the value of attribute total_sql_duration_ms.
23 24 25 |
# File 'lib/rails_console_pro/profile_result.rb', line 23 def total_sql_duration_ms @total_sql_duration_ms end |
#write_query_count ⇒ Object (readonly)
Returns the value of attribute write_query_count.
23 24 25 |
# File 'lib/rails_console_pro/profile_result.rb', line 23 def write_query_count @write_query_count end |
Instance Method Details
#cache_activity? ⇒ Boolean
72 73 74 |
# File 'lib/rails_console_pro/profile_result.rb', line 72 def cache_activity? cache_hits.positive? || cache_misses.positive? || cache_writes.positive? end |
#duplicate_queries? ⇒ Boolean
80 81 82 |
# File 'lib/rails_console_pro/profile_result.rb', line 80 def duplicate_queries? duplicate_queries.any? end |
#error? ⇒ Boolean
68 69 70 |
# File 'lib/rails_console_pro/profile_result.rb', line 68 def error? !error.nil? end |
#export_to_file(file_path, format: nil) ⇒ Object
104 105 106 |
# File 'lib/rails_console_pro/profile_result.rb', line 104 def export_to_file(file_path, format: nil) FormatExporter.export_to_file(self, file_path, format: format) end |
#label? ⇒ Boolean
64 65 66 |
# File 'lib/rails_console_pro/profile_result.rb', line 64 def label? !(label.nil? || (label.respond_to?(:empty?) && label.empty?)) end |
#query_samples? ⇒ Boolean
84 85 86 |
# File 'lib/rails_console_pro/profile_result.rb', line 84 def query_samples? query_samples.any? end |
#read_query_count ⇒ Object
88 89 90 |
# File 'lib/rails_console_pro/profile_result.rb', line 88 def read_query_count query_count - write_query_count end |
#slow_queries? ⇒ Boolean
76 77 78 |
# File 'lib/rails_console_pro/profile_result.rb', line 76 def slow_queries? slow_queries.any? end |
#to_html(style: :default) ⇒ Object
100 101 102 |
# File 'lib/rails_console_pro/profile_result.rb', line 100 def to_html(style: :default) FormatExporter.to_html(self, title: "Profile: #{label || 'Session'}", style: style) end |
#to_json(pretty: true) ⇒ Object
92 93 94 |
# File 'lib/rails_console_pro/profile_result.rb', line 92 def to_json(pretty: true) FormatExporter.to_json(self, pretty: pretty) end |
#to_yaml ⇒ Object
96 97 98 |
# File 'lib/rails_console_pro/profile_result.rb', line 96 def to_yaml FormatExporter.to_yaml(self) end |