class Stackprofiler::Run

Attributes

profile[RW]
timestamp[RW]
url[RW]

Public Class Methods

new(url, profile, timestamp) click to toggle source
# File lib/stackprofiler/run_data_source.rb, line 7
def initialize(url, profile, timestamp)
  @url = url
  @profile = profile
  @timestamp = timestamp
end

Public Instance Methods

code_cache() click to toggle source
# File lib/stackprofiler/run_data_source.rb, line 13
def code_cache
  @code_cache ||= RunCodeCache.new @profile
end
duration() click to toggle source
# File lib/stackprofiler/run_data_source.rb, line 35
def duration
  profile[:samples] * profile[:interval] / 1e6
end
gem_breakdown() click to toggle source
# File lib/stackprofiler/run_data_source.rb, line 39
def gem_breakdown
  bottom_frames = stacks.map &:last
  frames = bottom_frames.map {|addr| profile[:frames][addr] }

  gems = frames.map do |frame|
    case frame[:file]
      when %r{gems/(\D\w+)}
        $1
      when %r{#{RbConfig::CONFIG['rubylibdir']}}
        'stdlib'
      else
        '(app)'
    end
  end

  gems.group_by {|g| g }.map {|k, v| [k, v.count] }.sort_by(&:last).reverse.to_h
end
stacks(use_weights=false) click to toggle source
# File lib/stackprofiler/run_data_source.rb, line 17
def stacks use_weights=false
  @stacks ||= begin
    off = 0
    stacks = []
    raw = @profile[:raw]
    while off < raw.length
      len = raw[off]
      these_frames = raw[off + 1..off + len]
      weight = raw[off + len + 1]
      off += len + 2

      times = use_weights ? weight : 1
      times.times { stacks.push these_frames }
    end
    stacks
  end
end