Create top-level profile timing nodes for multiple template renders

This commit is contained in:
Dylan Thacker-Smith
2020-12-09 10:06:02 -05:00
parent 7960826552
commit da581d988a
3 changed files with 67 additions and 66 deletions
+9 -2
View File
@@ -103,12 +103,19 @@ class ProfilerTest < Minitest::Test
with_custom_tag('sleep', SleepTag) do
context = Liquid::Context.new
t = Liquid::Template.parse("{% sleep 0.001 %}", profile: true)
context.template_name = 'index'
t.render!(context)
first_render_time = context.profiler.total_render_time
context.template_name = 'layout'
first_render_time = context.profiler.total_time
t.render!(context)
profiler = context.profiler
children = profiler.children
assert_operator(first_render_time, :>=, 0.001)
assert_operator(context.profiler.total_render_time, :>=, 0.001 + first_render_time)
assert_operator(profiler.total_time, :>=, 0.001 + first_render_time)
assert_equal(["index", "layout"], children.map(&:template_name))
assert_equal([nil, nil], children.map(&:code))
assert_equal(profiler.total_time, children.map(&:total_time).reduce(&:+))
end
end