Class: Stackflame
- Inherits:
-
Object
- Object
- Stackflame
- Defined in:
- lib/stackflame.rb,
lib/stackflame/version.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ interval: 1000, mode: :cpu, raw: true, }.freeze
- VERSION =
"0.2.0"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.profile(options = {}, &block) ⇒ Object
12 13 14 15 16 |
# File 'lib/stackflame.rb', line 12 def self.profile( = {}, &block) stackflame = self.new stackflame.run(, &block) stackflame.open_flamegraph end |
Instance Method Details
#open_flamegraph ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/stackflame.rb', line 27 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(options = {}, &block) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/stackflame.rb', line 18 def run( = {}, &block) = DEFAULT_OPTIONS.merge() result = StackProf.run(, &block) File.open(temp_js_path, 'w') do |f| StackProf::Report.new(result).print_flamegraph(f) end end |