Class: Stackflame
- Inherits:
-
Object
- Object
- Stackflame
- Defined in:
- lib/stackflame.rb,
lib/stackflame/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.profile(mode: :cpu, &block) ⇒ Object
6 7 8 9 10 |
# File 'lib/stackflame.rb', line 6 def self.profile(mode: :cpu, &block) stackflame = self.new stackflame.run(mode, &block) stackflame.open_flamegraph end |
Instance Method Details
#open_flamegraph ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/stackflame.rb', line 20 def open_flamegraph if system("which osascript > /dev/null") # NOTE: `open` can't open path with query string `osascript -e 'open location "#{flamegraph_path}"'` else puts "This OS is not supported. Please open: #{flamegraph_path}" end end |
#run(mode, &block) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/stackflame.rb', line 12 def run(mode, &block) result = StackProf.run(mode: mode, raw: true, &block) File.open(temp_js_path, 'w') do |f| StackProf::Report.new(result).print_flamegraph(f) end end |