45 lines
772 B
Ruby
45 lines
772 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "bundler/inline"
|
|
|
|
gemfile ENV.key?("INSTALL_GEMS") do
|
|
source "https://rubygems.org"
|
|
gem "hrb", path: "../"
|
|
gem "memory_profiler"
|
|
gem "ruby-prof"
|
|
gem "stackprof"
|
|
end
|
|
|
|
def run
|
|
10_000.times do
|
|
Hrb::Template.render_file("../test/fixtures/basic.html.rb", locals: {created: "2019-06-17", numbers: (1..10)})
|
|
end
|
|
end
|
|
|
|
def prof
|
|
result = RubyProf.profile do
|
|
run
|
|
end
|
|
|
|
printer = RubyProf::MultiPrinter.new(result)
|
|
printer.print(path: "./profile", profile: "profile")
|
|
end
|
|
|
|
def stackprof
|
|
StackProf.run(mode: :wall, out: "./profile/stackprof.dump", interval: 1000) do
|
|
run
|
|
end
|
|
end
|
|
|
|
def memory_profiler
|
|
report = MemoryProfiler.report do
|
|
run
|
|
end
|
|
|
|
report.pretty_print
|
|
end
|
|
|
|
memory_profiler
|
|
prof
|
|
stackprof
|