Class: Vernier::Collector::CustomCollector

Inherits:
Vernier::Collector show all
Defined in:
lib/vernier/collector.rb

Instance Attribute Summary

Attributes inherited from Vernier::Collector

#stack_table

Instance Method Summary collapse

Methods inherited from Vernier::Collector

#add_marker, #current_time, new, #record_interval, #stop

Constructor Details

#initialize(mode, options) ⇒ CustomCollector

Returns a new instance of CustomCollector.



9
10
11
12
13
14
15
16
17
# File 'lib/vernier/collector.rb', line 9

def initialize(mode, options)
  @stack_table = StackTable.new

  @samples = []
  @timestamps = []

  @started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond)
  super
end

Instance Method Details

#finishObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/vernier/collector.rb', line 27

def finish
  result = Result.new
  result.instance_variable_set(:@threads, {
    0 => {
      tid: 0,
      name: "custom",
      started_at: @started_at,
      samples: @samples,
      weights: [1] * @samples.size,
      timestamps: @timestamps,
      sample_categories: [0] * @samples.size,
    }
  })
  result.instance_variable_set(:@meta, {
    started_at: @started_at
  })
  result
end

#sampleObject



19
20
21
22
# File 'lib/vernier/collector.rb', line 19

def sample
  @samples << @stack_table.current_stack
  @timestamps << Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond)
end

#startObject



24
25
# File 'lib/vernier/collector.rb', line 24

def start
end