Sha256: c9ab55c93acfeb44b80ac241334386f2d28bc093a6a4eb1466b9ac2a4b253a16

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

#!/usr/bin/env ruby
# rubocop:disable all

require 'bundler/setup'
require 'json'
require 'ruby-prof'
require 'stackprof'

require_relative './examples'

flows_ten_steps = FlowsTenSteps.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)

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)

#
# 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))

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))

puts
puts 'Install speedscope:'
puts '  npm i -g speedscope'
puts
puts "speedscope profile/#{build_output_name}.json"
puts "speedscope profile/#{exec_output_name}.json"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flows-0.1.0 bin/profile_10steps