bin/profile_10steps in flows-0.1.0 vs bin/profile_10steps in flows-0.2.0
- old
+ new
@@ -7,58 +7,100 @@
require 'stackprof'
require_relative './examples'
flows_ten_steps = FlowsTenSteps.new
+flows_railway_ten_steps = FlowsRailwayTenSteps.new
build_output_name = '10steps_build_10k_times'
exec_output_name = '10steps_execution_10k_times'
#
# RubyProf
#
RubyProf.measure_mode = RubyProf::WALL_TIME
+
puts 'Build with RubyProf...'
+
result = RubyProf.profile do
10_000.times do
FlowsTenSteps.new
end
end
printer = RubyProf::MultiPrinter.new(result)
-printer.print(path: 'profile', profile: build_output_name)
+printer.print(path: 'profile', profile: "#{build_output_name}_operaion")
+result = RubyProf.profile do
+ 10_000.times do
+ FlowsRailwayTenSteps.new
+ end
+end
+printer = RubyProf::MultiPrinter.new(result)
+printer.print(path: 'profile', profile: "#{build_output_name}_railway")
+
+
puts 'Execution with RubyProf...'
+
result = RubyProf.profile do
10_000.times {
flows_ten_steps.call
}
end
printer = RubyProf::MultiPrinter.new(result)
-printer.print(path: 'profile', profile: exec_output_name)
+printer.print(path: 'profile', profile: "#{exec_output_name}_operation")
+result = RubyProf.profile do
+ 10_000.times {
+ flows_railway_ten_steps.call
+ }
+end
+printer = RubyProf::MultiPrinter.new(result)
+printer.print(path: 'profile', profile: "#{exec_output_name}_railway")
+
+
#
# StackProf
#
puts 'Build with StackProf...'
+
result = StackProf.run(mode: :wall, raw: true) do
10_000.times do
FlowsTenSteps.new
end
end
-File.write("profile/#{build_output_name}.json", JSON.generate(result))
+File.write("profile/#{build_output_name}_operation.json", JSON.generate(result))
+result = StackProf.run(mode: :wall, raw: true) do
+ 10_000.times do
+ FlowsRailwayTenSteps.new
+ end
+end
+File.write("profile/#{build_output_name}_railway.json", JSON.generate(result))
+
+
puts 'Execution with StackProf...'
+
result = StackProf.run(mode: :wall, raw: true) do
10_000.times do
flows_ten_steps.call
end
end
-File.write("profile/#{exec_output_name}.json", JSON.generate(result))
+File.write("profile/#{exec_output_name}_operation.json", JSON.generate(result))
+result = StackProf.run(mode: :wall, raw: true) do
+ 10_000.times do
+ flows_railway_ten_steps.call
+ end
+end
+File.write("profile/#{exec_output_name}_railway.json", JSON.generate(result))
+
+
puts
puts 'Install speedscope:'
puts ' npm i -g speedscope'
puts
-puts "speedscope profile/#{build_output_name}.json"
-puts "speedscope profile/#{exec_output_name}.json"
+puts "speedscope profile/#{build_output_name}_operation.json"
+puts "speedscope profile/#{build_output_name}_railway.json"
+puts "speedscope profile/#{exec_output_name}_operation.json"
+puts "speedscope profile/#{exec_output_name}_railway.json"