mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 19:00:39 -07:00
Add env var for saving stackprof graphviz output
This commit is contained in:
@@ -8,10 +8,17 @@ profiler.run
|
|||||||
[:cpu, :object].each do |profile_type|
|
[:cpu, :object].each do |profile_type|
|
||||||
puts "Profiling in #{profile_type.to_s} mode..."
|
puts "Profiling in #{profile_type.to_s} mode..."
|
||||||
results = StackProf.run(mode: profile_type) do
|
results = StackProf.run(mode: profile_type) do
|
||||||
100.times do
|
200.times do
|
||||||
profiler.run
|
profiler.run
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if profile_type == :cpu && graph_filename = ENV['GRAPH_FILENAME']
|
||||||
|
File.open(graph_filename, 'w') do |f|
|
||||||
|
StackProf::Report.new(results).print_graphviz(nil, f)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
StackProf::Report.new(results).print_text(false, 20)
|
StackProf::Report.new(results).print_text(false, 20)
|
||||||
File.write(ENV['FILENAME'] + "." + profile_type.to_s, Marshal.dump(results)) if ENV['FILENAME']
|
File.write(ENV['FILENAME'] + "." + profile_type.to_s, Marshal.dump(results)) if ENV['FILENAME']
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user