Profile liquid rendering

Add a simple profiling system to liquid rendering. Each
liquid tag ({{ }} and {% %}) is processed through this profiling,
keeping track of the partial name (in the case of {% include %}), line
number, and the time it took to render the tag. In the case of {%
include %}, the profiler keeps track of the name of the partial and
properly links back tag rendering to the partial and line number for
easy lookup and dive down. With this, it's now possible to track down
exactly how long each tag takes to render.

These hooks get installed and uninstalled on an as-need basis so by
default there is no impact on the overall liquid execution speed.
This commit is contained in:
Jason Roelofs
2014-06-05 14:13:19 -04:00
parent d3b113d2e1
commit 173a58d36a
13 changed files with 427 additions and 9 deletions

View File

@@ -14,6 +14,7 @@ module Liquid
FilterParser = /(?:#{FilterSeparator}|(?:\s*(?:#{QuotedFragment}|#{ArgumentSeparator})\s*)+)/o
EasyParse = /\A *(\w+(?:\.\w+)*) *\z/
attr_accessor :filters, :name, :warnings
attr_accessor :line_number
def initialize(markup, options = {})
@markup = markup
@@ -34,6 +35,10 @@ module Liquid
end
end
def raw
@markup
end
def lax_parse(markup)
@filters = []
if markup =~ /\s*(#{QuotedFragment})(.*)/om