From 098c89b5f59e5fe3f17b34b5b53838e94add8610 Mon Sep 17 00:00:00 2001 From: Justin Li Date: Mon, 3 Nov 2014 14:53:16 -0500 Subject: [PATCH 1/2] Convenience methods for raising terminator syntax errors --- lib/liquid/block_body.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/liquid/block_body.rb b/lib/liquid/block_body.rb index 6d356e9..79582b8 100644 --- a/lib/liquid/block_body.rb +++ b/lib/liquid/block_body.rb @@ -34,7 +34,7 @@ module Liquid return yield tag_name, markup end else - raise SyntaxError.new(options[:locale].t("errors.syntax.tag_termination".freeze, :token => token, :tag_end => TagEnd.inspect)) + raise_missing_tag_terminator(token, options) end when token.start_with?(VARSTART) new_var = create_variable(token, options) @@ -117,6 +117,14 @@ module Liquid markup = token.is_a?(Token) ? token.child(content.first) : content.first return Variable.new(markup, options) end + raise_missing_variable_terminator(token, options) + end + + def raise_missing_tag_terminator(token, options) + raise SyntaxError.new(options[:locale].t("errors.syntax.tag_termination".freeze, :token => token, :tag_end => TagEnd.inspect)) + end + + def raise_missing_variable_terminator(token, options) raise SyntaxError.new(options[:locale].t("errors.syntax.variable_termination".freeze, :token => token, :tag_end => VariableEnd.inspect)) end end From 4e870302b105badfc39e1adeedaba1b0fd38404a Mon Sep 17 00:00:00 2001 From: Justin Li Date: Mon, 3 Nov 2014 14:53:16 -0500 Subject: [PATCH 2/2] Add env var for saving stackprof graphviz output --- performance/profile.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/performance/profile.rb b/performance/profile.rb index 57b6187..1feba24 100644 --- a/performance/profile.rb +++ b/performance/profile.rb @@ -8,10 +8,17 @@ profiler.run [:cpu, :object].each do |profile_type| puts "Profiling in #{profile_type.to_s} mode..." results = StackProf.run(mode: profile_type) do - 100.times do + 200.times do profiler.run end end + + if profile_type == :cpu && graph_filename = ENV['GRAPH_FILENAME'] + File.open(graph_filename, 'w') do |f| + StackProf::Report.new(results).print_graphviz(nil, f) + end + end + StackProf::Report.new(results).print_text(false, 20) File.write(ENV['FILENAME'] + "." + profile_type.to_s, Marshal.dump(results)) if ENV['FILENAME'] end