mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-03 09:05:13 -07:00
Merge pull request #485 from Shopify/lazy-load-profiler-hooks
Defer loading profiler hooks
This commit is contained in:
@@ -73,6 +73,3 @@ require 'liquid/token'
|
|||||||
# Load all the tags of the standard library
|
# Load all the tags of the standard library
|
||||||
#
|
#
|
||||||
Dir[File.dirname(__FILE__) + '/liquid/tags/*.rb'].each { |f| require f }
|
Dir[File.dirname(__FILE__) + '/liquid/tags/*.rb'].each { |f| require f }
|
||||||
|
|
||||||
require 'liquid/profiler'
|
|
||||||
require 'liquid/profiler/hooks'
|
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
|
require 'liquid/profiler/hooks'
|
||||||
|
|
||||||
module Liquid
|
module Liquid
|
||||||
|
|
||||||
# Profiler enables support for profiling template rendering to help track down performance issues.
|
# Profiler enables support for profiling template rendering to help track down performance issues.
|
||||||
#
|
#
|
||||||
# To enable profiling, pass the <tt>profile: true</tt> option to <tt>Liquid::Template.parse</tt>. Then, after
|
# To enable profiling, first require 'liquid/profiler'.
|
||||||
# <tt>Liquid::Template#render</tt> is called, the template object makes available an instance of this
|
# Then, to profile a parse/render cycle, pass the <tt>profile: true</tt> option to <tt>Liquid::Template.parse</tt>.
|
||||||
|
# After <tt>Liquid::Template#render</tt> is called, the template object makes available an instance of this
|
||||||
# class via the <tt>Liquid::Template#profiler</tt> method.
|
# class via the <tt>Liquid::Template#profiler</tt> method.
|
||||||
#
|
#
|
||||||
# template = Liquid::Template.parse(template_content, profile: true)
|
# template = Liquid::Template.parse(template_content, profile: true)
|
||||||
|
|||||||
@@ -250,6 +250,8 @@ module Liquid
|
|||||||
|
|
||||||
def with_profiling
|
def with_profiling
|
||||||
if @profiling && !@options[:included]
|
if @profiling && !@options[:included]
|
||||||
|
raise "Profiler not loaded, require 'liquid/profiler' first" unless defined?(Liquid::Profiler)
|
||||||
|
|
||||||
@profiler = Profiler.new
|
@profiler = Profiler.new
|
||||||
@profiler.start
|
@profiler.start
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ require 'spy/integration'
|
|||||||
|
|
||||||
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
|
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
|
||||||
require 'liquid.rb'
|
require 'liquid.rb'
|
||||||
|
require 'liquid/profiler'
|
||||||
|
|
||||||
mode = :strict
|
mode = :strict
|
||||||
if env_mode = ENV['LIQUID_PARSER_MODE']
|
if env_mode = ENV['LIQUID_PARSER_MODE']
|
||||||
|
|||||||
Reference in New Issue
Block a user