From 5a48edae6a2d61cccc6aeca550e74d8c3b6033e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lourens=20Naud=C3=A9?= Date: Tue, 5 May 2015 23:00:28 -0400 Subject: [PATCH] Introduce support for memory usage profiles --- Gemfile | 1 + Rakefile | 14 ++++++++++++++ performance/memory.rb | 13 +++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 performance/memory.rb diff --git a/Gemfile b/Gemfile index 29524192..13d46c08 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ source 'https://rubygems.org' gemspec gem 'stackprof', platforms: :mri_21 +gem 'allocation_tracer', platforms: :mri_21 group :test do gem 'spy', '0.4.1' diff --git a/Rakefile b/Rakefile index 62960277..d86404ce 100755 --- a/Rakefile +++ b/Rakefile @@ -71,6 +71,20 @@ namespace :profile do end +namespace :memory do + + desc "Run the liquid memory tracer" + task :run do + ruby "./performance/memory.rb" + end + + desc "Run the liquid memory tracer with strict parsing" + task :strict do + ruby "./performance/memory.rb strict" + end + +end + desc "Run example" task :example do ruby "-w -d -Ilib example/server/server.rb" diff --git a/performance/memory.rb b/performance/memory.rb new file mode 100644 index 00000000..ed8ba465 --- /dev/null +++ b/performance/memory.rb @@ -0,0 +1,13 @@ +require 'allocation_tracer' rescue fail("install allocation_tracer extension/gem") +require File.dirname(__FILE__) + '/theme_runner' + +Liquid::Template.error_mode = ARGV.first.to_sym if ARGV.first +profiler = ThemeRunner.new + +require 'allocation_tracer/trace' + +puts "Profiling memory usage..." + +200.times do + profiler.run +end