Sha256: a165df963277e6570b1b2f90bc53f9e6a0bd47b5a580281d38a56884e909c23c

Contents?: true

Size: 604 Bytes

Versions: 1

Compression:

Stored size: 604 Bytes

Contents

require 'stackprof'
require 'tmpdir'

HOTCH_VIEWER = ENV['HOTCH_VIEWER']

NAME = $0.gsub(/\W/, '_')

StackProf.start

def system!(*args)
  system(*args) or raise "system call failed: #{args.join(' ')}"
end

at_exit do
  StackProf.stop

  dir = Dir.mktmpdir("hotch.#{NAME}")
  dump = File.open(File.join(dir, "profile.dump"), "wb")
  svg = File.join(File.join(dir, "profile.svg"))

  StackProf::Report.new(StackProf.results).print_graphviz(nil, dump)

  dump.close

  system! "dot", "-Tsvg", "-o", svg, dump.path

  puts "Profile SVG: #{svg}"

  if viewer = HOTCH_VIEWER
    system! viewer, svg
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hotch-0.0.1 lib/hotch.rb