mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Added a Rake task for benchmarking. Use with rake benchmark (TIMES=n)
git-svn-id: svn://hamptoncatlin.com/haml/trunk@36 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
parent
5374974646
commit
1a2040b1d9
2 changed files with 15 additions and 7 deletions
10
Rakefile
10
Rakefile
|
@ -6,13 +6,21 @@ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
||||||
desc 'Default: run unit tests.'
|
desc 'Default: run unit tests.'
|
||||||
task :default => :test
|
task :default => :test
|
||||||
|
|
||||||
desc 'Test the haml plugin.'
|
desc 'Test the HAML plugin'
|
||||||
Rake::TestTask.new(:test) do |t|
|
Rake::TestTask.new(:test) do |t|
|
||||||
t.libs << 'lib'
|
t.libs << 'lib'
|
||||||
t.pattern = 'test/**/*_test.rb'
|
t.pattern = 'test/**/*_test.rb'
|
||||||
t.verbose = true
|
t.verbose = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc 'Benchmark HAML against ERb. The benchmark routine is run 100. Use TIMES=n to override'
|
||||||
|
task :benchmark do
|
||||||
|
puts '-'*51, "+ Benchmark: HAML vs. ERb", '-'*51
|
||||||
|
puts "Running benchmark #{ENV['TIMES']} times..." if ENV['TIMES']
|
||||||
|
puts `ruby test/benchmark.rb #{ENV['TIMES']}`
|
||||||
|
puts '-'*51
|
||||||
|
end
|
||||||
|
|
||||||
desc 'Generate documentation for the haml plugin.'
|
desc 'Generate documentation for the haml plugin.'
|
||||||
Rake::RDocTask.new(:rdoc) do |rdoc|
|
Rake::RDocTask.new(:rdoc) do |rdoc|
|
||||||
rdoc.rdoc_dir = 'rdoc'
|
rdoc.rdoc_dir = 'rdoc'
|
||||||
|
|
|
@ -5,14 +5,14 @@ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'action_view'
|
require 'action_view'
|
||||||
|
|
||||||
include Haml::Helper
|
include Haml::Helpers
|
||||||
|
|
||||||
ActionView::Base.register_template_handler("haml", Haml::Engine)
|
ActionView::Base.register_template_handler("haml", Haml::Engine)
|
||||||
@base = ActionView::Base.new(File.dirname(__FILE__))
|
@base = ActionView::Base.new(File.dirname(__FILE__))
|
||||||
|
|
||||||
RUNS = 2000
|
RUNS = (ARGV[0] || 100).to_i
|
||||||
Benchmark.bm do |x|
|
|
||||||
x.report("haml: ") { RUNS.times { @base.render("templates/standard"); } }
|
|
||||||
x.report("rhtml:") { RUNS.times { @base.render( "rhtml/standard"); } }
|
|
||||||
end
|
|
||||||
|
|
||||||
|
Benchmark.bm do |b|
|
||||||
|
b.report("haml: ") { RUNS.times { @base.render "templates/standard" } }
|
||||||
|
b.report("rhtml:") { RUNS.times { @base.render "rhtml/standard" } }
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue