Class: RspecProfiling::Example
- Inherits:
-
Object
- Object
- RspecProfiling::Example
- Defined in:
- lib/rspec_profiling/example.rb
Constant Summary collapse
- IGNORED_QUERIES_PATTERN =
%r{( pg_table| pg_attribute| pg_namespace| show\stables| pragma| sqlite_master/rollback| ^TRUNCATE TABLE| ^ALTER TABLE| ^BEGIN| ^COMMIT| ^ROLLBACK| ^RELEASE| ^SAVEPOINT )}xi
Instance Method Summary collapse
- #description ⇒ Object
- #exception ⇒ Object
- #file ⇒ Object
-
#initialize(example) ⇒ Example
constructor
A new instance of Example.
- #line_number ⇒ Object
- #log_query(query, start, finish) ⇒ Object
- #log_request(request, start, finish) ⇒ Object
- #query_count ⇒ Object
- #query_time ⇒ Object
- #request_count ⇒ Object
- #request_time ⇒ Object
- #status ⇒ Object
- #time ⇒ Object
Constructor Details
#initialize(example) ⇒ Example
Returns a new instance of Example.
21 22 23 24 |
# File 'lib/rspec_profiling/example.rb', line 21 def initialize(example) @example = example @counts = Hash.new(0) end |
Instance Method Details
#description ⇒ Object
34 35 36 |
# File 'lib/rspec_profiling/example.rb', line 34 def description [:full_description] end |
#exception ⇒ Object
42 43 44 |
# File 'lib/rspec_profiling/example.rb', line 42 def exception execution_result.exception end |
#file ⇒ Object
26 27 28 |
# File 'lib/rspec_profiling/example.rb', line 26 def file [:file_path] end |
#line_number ⇒ Object
30 31 32 |
# File 'lib/rspec_profiling/example.rb', line 30 def line_number [:line_number] end |
#log_query(query, start, finish) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/rspec_profiling/example.rb', line 66 def log_query(query, start, finish) unless query[:sql] =~ IGNORED_QUERIES_PATTERN counts[:query_count] += 1 counts[:query_time] += (finish - start) end end |
#log_request(request, start, finish) ⇒ Object
73 74 75 76 |
# File 'lib/rspec_profiling/example.rb', line 73 def log_request(request, start, finish) counts[:request_count] += 1 counts[:request_time] += request[:view_runtime].to_f end |
#query_count ⇒ Object
50 51 52 |
# File 'lib/rspec_profiling/example.rb', line 50 def query_count counts[:query_count] end |
#query_time ⇒ Object
54 55 56 |
# File 'lib/rspec_profiling/example.rb', line 54 def query_time counts[:query_time] end |
#request_count ⇒ Object
58 59 60 |
# File 'lib/rspec_profiling/example.rb', line 58 def request_count counts[:request_count] end |
#request_time ⇒ Object
62 63 64 |
# File 'lib/rspec_profiling/example.rb', line 62 def request_time counts[:request_time] end |
#status ⇒ Object
38 39 40 |
# File 'lib/rspec_profiling/example.rb', line 38 def status execution_result.status end |
#time ⇒ Object
46 47 48 |
# File 'lib/rspec_profiling/example.rb', line 46 def time execution_result.run_time end |