Class: RspecProfiling::Run

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_profiling/run.rb

Instance Method Summary collapse

Constructor Details

#initialize(collector = RspecProfiling.config.collector.new, vcs = RspecProfiling.config.vcs.new, events = RspecProfiling.config.events) ⇒ Run

Returns a new instance of Run.



11
12
13
14
15
16
17
18
19
# File 'lib/rspec_profiling/run.rb', line 11

def initialize(collector = RspecProfiling.config.collector.new,
               vcs = RspecProfiling.config.vcs.new,
               events = RspecProfiling.config.events)

  @collector = collector
  @vcs       = vcs
  @events    = events
  @seed      = RSpec.configuration.seed
end

Instance Method Details

#example_finished(*args) ⇒ Object Also known as: example_passed, example_failed



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rspec_profiling/run.rb', line 33

def example_finished(*args)
  collector.insert({
    branch:        vcs.branch,
    commit_hash:   vcs.sha,
    seed:          @seed,
    date:          vcs.time,
    file:          @current_example.file,
    line_number:   @current_example.line_number,
    description:   @current_example.description,
    status:        @current_example.status,
    exception:     @current_example.exception,
    time:          @current_example.time,
    owner_tag:     @current_example.owner_tag,
    query_count:   @current_example.query_count,
    query_time:    @current_example.query_time,
    request_count: @current_example.request_count,
    request_time:  @current_example.request_time,
    events:        @events,
    event_counts:  @current_example.event_counts,
    event_times:   @current_example.event_times,
    event_events:  @current_example.event_events,
    start_memory:  @start_memory,
    end_memory:    end_memory
  })
end

#example_started(example) ⇒ Object



27
28
29
30
31
# File 'lib/rspec_profiling/run.rb', line 27

def example_started(example)
  start_recording_memory
  example = example.example if example.respond_to?(:example)
  @current_example = Example.new(example)
end

#start(*args) ⇒ Object



21
22
23
24
25
# File 'lib/rspec_profiling/run.rb', line 21

def start(*args)
  start_counting_queries
  start_counting_requests
  start_counting_events
end