class SpeedGun::Source::Line

Attributes

allocations[R]
calls[R]
code[R]
cpu[R]
id[R]
line[R]
wall[R]

Public Class Methods

from_hash(hash, id = nil) click to toggle source
# File lib/speed_gun/source.rb, line 11
def self.from_hash(hash, id = nil)
  keys = %w(line code wall cpu calls allocations)
  vals = keys.map { |k| hash[k] }
  new(*vals).tap do |line|
    line.instance_variable_set(:@id, id) if id
  end
end
new(line, code, wall, cpu, calls, allocations) click to toggle source
# File lib/speed_gun/source.rb, line 19
def initialize(line, code, wall, cpu, calls, allocations)
  @id = SecureRandom.uuid
  @line, @code, @wall, @cpu, @calls, @allocations = line, code, wall, cpu, calls, allocations
end

Public Instance Methods

to_hash() click to toggle source
# File lib/speed_gun/source.rb, line 28
def to_hash
  {
    line: line,
    code: code,
    wall: wall,
    cpu: cpu,
    calls: calls,
    allocations: allocations
  }
end
to_s() click to toggle source
# File lib/speed_gun/source.rb, line 24
def to_s
  format('% 8.1fms + % 8.1fms (% 5d) % 5d allocs | %04d %s', cpu / 1000.0, (wall - cpu) / 1000.0, calls, allocations, line, code)
end