rake memory_profile:run

This commit is contained in:
Florian Weingarten
2019-04-17 18:33:59 +01:00
parent b0629f17f7
commit c67b77709d
3 changed files with 38 additions and 2 deletions

View File

@@ -5,10 +5,13 @@ end
gemspec
gem 'stackprof', platforms: :mri
group :benchmark, :test do
gem 'benchmark-ips'
gem 'memory_profiler'
install_if -> { RUBY_PLATFORM !~ /mingw|mswin/ } do
gem 'stackprof'
end
end
group :test do

View File

@@ -85,6 +85,13 @@ namespace :profile do
end
end
namespace :memory_profile do
desc "Run memory profiler"
task :run do
ruby "./performance/memory_profile.rb"
end
end
desc "Run example"
task :example do
ruby "-w -d -Ilib example/server/server.rb"

View File

@@ -0,0 +1,26 @@
# frozen_string_literal: true
require 'benchmark/ips'
require 'memory_profiler'
require_relative 'theme_runner'
def profile(phase, &block)
puts
puts "#{phase}:"
puts
report = MemoryProfiler.report(&block)
report.pretty_print(
color_output: true,
scale_bytes: true,
detailed_report: true
)
end
Liquid::Template.error_mode = ARGV.first.to_sym if ARGV.first
profiler = ThemeRunner.new
profile("Parsing") { profiler.compile }
profile("Rendering") { profiler.render }