mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 11:20:41 -07:00
Merge pull request #1092 from Shopify/rake-memory-profiler-task
rake memory_profile:run
This commit is contained in:
@@ -5,10 +5,13 @@ end
|
|||||||
|
|
||||||
gemspec
|
gemspec
|
||||||
|
|
||||||
gem 'stackprof', platforms: :mri
|
|
||||||
|
|
||||||
group :benchmark, :test do
|
group :benchmark, :test do
|
||||||
gem 'benchmark-ips'
|
gem 'benchmark-ips'
|
||||||
|
gem 'memory_profiler'
|
||||||
|
|
||||||
|
install_if -> { RUBY_PLATFORM !~ /mingw|mswin/ } do
|
||||||
|
gem 'stackprof'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
|
|||||||
@@ -85,6 +85,13 @@ namespace :profile do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
namespace :memory_profile do
|
||||||
|
desc "Run memory profiler"
|
||||||
|
task :run do
|
||||||
|
ruby "./performance/memory_profile.rb"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
desc "Run example"
|
desc "Run example"
|
||||||
task :example do
|
task :example do
|
||||||
ruby "-w -d -Ilib example/server/server.rb"
|
ruby "-w -d -Ilib example/server/server.rb"
|
||||||
|
|||||||
@@ -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 }
|
||||||
Reference in New Issue
Block a user