class Bixby::Bench::Sample

Attributes

block[R]
label[R]

Public Class Methods

new(label, block, sample_size, memory) click to toggle source
# File lib/bixby/bench/sample.rb, line 8
def initialize(label, block, sample_size, memory)
  @label       = label
  @block       = block
  @sample_size = sample_size
  @memory      = memory
end

Public Instance Methods

call() click to toggle source
# File lib/bixby/bench/sample.rb, line 15
def call
  @block.call
end
measure() click to toggle source
# File lib/bixby/bench/sample.rb, line 19
def measure
  report = Report.new
  report.tms = Benchmark.measure { @sample_size.times { self.call } }

  if @memory then
    report.allocation_stats = AllocationStats.new(burn: 5).trace { self.call }
  end

  return report
end