File: stackprof

package info (click to toggle)
ruby-haml 6.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,004 kB
  • sloc: ruby: 9,908; sh: 23; makefile: 11
file content (27 lines) | stat: -rwxr-xr-x 705 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env ruby

require 'bundler/setup'
require 'hamlit'
require 'stackprof'

def open_flamegraph(report)
  temp = `mktemp /tmp/stackflame-XXXXXXXX`.strip
  data_path = "#{temp}.js"
  system("mv #{temp} #{data_path}")

  File.open(data_path, 'w') do |f|
    report.print_flamegraph(f)
  end

  viewer_path = File.join(`bundle show stackprof`.strip, 'lib/stackprof/flamegraph/viewer.html')
  url = "file://#{viewer_path}?data=#{data_path}"
  system(%Q[osascript -e 'open location "#{url}"'])
end

haml = File.read(ARGV.first)
StackProf.start(mode: :wall, interval: 1, raw: false)
Hamlit::Engine.new.call(haml)
StackProf.stop

report = StackProf::Report.new(StackProf.results)
report.print_text(false)