fix benchmarks

This commit is contained in:
Tobias Lutke
2012-10-28 21:37:07 -04:00
parent 6c2fde5eea
commit 6b64bfb53e
3 changed files with 29 additions and 3 deletions
+2 -1
View File
@@ -5,6 +5,7 @@ require File.dirname(__FILE__) + '/theme_runner'
profiler = ThemeRunner.new
Benchmark.bmbm do |x|
x.report("parse & run:") { 10.times { profiler.run(false) } }
x.report("parse:") { 100.times { profiler.compile } }
x.report("parse & run:") { 100.times { profiler.run } }
end
+1 -1
View File
@@ -6,7 +6,7 @@ profiler = ThemeRunner.new
puts 'Running profiler...'
results = profiler.run
results = profiler.run_profile
puts 'Success'
puts
+26 -1
View File
@@ -27,8 +27,33 @@ class ThemeRunner
end.compact
end
def compile
# Dup assigns because will make some changes to them
def run()
@tests.each do |liquid, layout, template_name|
tmpl = Liquid::Template.new
tmpl.parse(liquid)
tmpl = Liquid::Template.new
tmpl.parse(layout)
end
end
def run
# Dup assigns because will make some changes to them
assigns = Database.tables.dup
@tests.each do |liquid, layout, template_name|
# Compute page_tempalte outside of profiler run, uninteresting to profiler
page_template = File.basename(template_name, File.extname(template_name))
compile_and_render(liquid, layout, assigns, page_template)
end
end
def run_profile
RubyProf.measure_mode = RubyProf::WALL_TIME
# Dup assigns because will make some changes to them