mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Cleanup benchmark code
This commit is contained in:
parent
70ab3e2edf
commit
b6445fcaf5
3 changed files with 5 additions and 50 deletions
|
@ -5,13 +5,10 @@ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'), File.dirname(__FILE__
|
||||||
require_relative './context'
|
require_relative './context'
|
||||||
require 'benchmark/ips'
|
require 'benchmark/ips'
|
||||||
|
|
||||||
require 'erb'
|
|
||||||
require 'erubis'
|
require 'erubis'
|
||||||
require 'faml'
|
require 'faml'
|
||||||
require 'haml'
|
require 'haml'
|
||||||
require 'slim'
|
require 'slim'
|
||||||
require 'tenjin'
|
|
||||||
require 'tilt'
|
|
||||||
require 'hamlit'
|
require 'hamlit'
|
||||||
|
|
||||||
class Benchmarks
|
class Benchmarks
|
||||||
|
@ -23,29 +20,19 @@ class Benchmarks
|
||||||
@erb_code = File.read(File.dirname(__FILE__) + '/view.erb')
|
@erb_code = File.read(File.dirname(__FILE__) + '/view.erb')
|
||||||
@haml_code = File.read(File.dirname(__FILE__) + '/view.haml')
|
@haml_code = File.read(File.dirname(__FILE__) + '/view.haml')
|
||||||
@slim_code = File.read(File.dirname(__FILE__) + '/view.slim')
|
@slim_code = File.read(File.dirname(__FILE__) + '/view.slim')
|
||||||
@rbhtml_path = File.dirname(__FILE__) + '/view.rbhtml'
|
|
||||||
|
|
||||||
init_compiled_benches
|
init_compiled_benches
|
||||||
end
|
end
|
||||||
|
|
||||||
def init_compiled_benches
|
def init_compiled_benches
|
||||||
erb = ERB.new(@erb_code)
|
|
||||||
erubis = Erubis::Eruby.new(@erb_code)
|
|
||||||
fast_erubis = Erubis::FastEruby.new(@erb_code)
|
|
||||||
haml_ugly = Haml::Engine.new(@haml_code, format: :html5, ugly: true)
|
|
||||||
tenjin = Tenjin::Engine.new.get_template(@rbhtml_path)
|
|
||||||
|
|
||||||
context = Context.new
|
context = Context.new
|
||||||
|
|
||||||
|
haml_ugly = Haml::Engine.new(@haml_code, format: :html5, ugly: true)
|
||||||
haml_ugly.def_method(context, :run_haml_ugly)
|
haml_ugly.def_method(context, :run_haml_ugly)
|
||||||
context.instance_eval %{
|
context.instance_eval %{
|
||||||
def run_erb; #{erb.src}; end
|
def run_erubis; #{Erubis::Eruby.new(@erb_code).src}; end
|
||||||
def run_erubis; #{erubis.src}; end
|
|
||||||
def run_temple_erb; #{Temple::ERB::Engine.new.call @erb_code}; end
|
|
||||||
def run_fast_erubis; #{fast_erubis.src}; end
|
|
||||||
def run_slim_ugly; #{Slim::Engine.new.call @slim_code}; end
|
def run_slim_ugly; #{Slim::Engine.new.call @slim_code}; end
|
||||||
def run_faml; #{Faml::Engine.new.call @haml_code}; end
|
def run_faml; #{Faml::Engine.new.call @haml_code}; end
|
||||||
def run_tenjin; _buf = ''; #{tenjin.script}; end
|
|
||||||
def run_hamlit; #{Hamlit::Engine.new.call @haml_code}; end
|
def run_hamlit; #{Hamlit::Engine.new.call @haml_code}; end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,14 +41,6 @@ class Benchmarks
|
||||||
bench('slim', Slim::VERSION) { context.run_slim_ugly }
|
bench('slim', Slim::VERSION) { context.run_slim_ugly }
|
||||||
bench('faml', Faml::VERSION) { context.run_faml }
|
bench('faml', Faml::VERSION) { context.run_faml }
|
||||||
bench('haml', Haml::VERSION) { context.run_haml_ugly }
|
bench('haml', Haml::VERSION) { context.run_haml_ugly }
|
||||||
|
|
||||||
if ENV['ALL']
|
|
||||||
erb_version = ERB.version.match(/\[([^ ]+)/)[1]
|
|
||||||
bench('tenjin', Tenjin::RELEASE) { context.run_tenjin }
|
|
||||||
bench('fast erubis', Erubis::VERSION) { context.run_fast_erubis }
|
|
||||||
bench('temple erb', Temple::VERSION) { context.run_temple_erb }
|
|
||||||
bench('erb', erb_version) { context.run_erb }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Simple Benchmark</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>#{ header }</h1>
|
|
||||||
<?rb unless item.empty? ?>
|
|
||||||
<ul>
|
|
||||||
<?rb for i in item ?>
|
|
||||||
<?rb if i[:current] ?>
|
|
||||||
<li><strong>#{ i[:name] }</strong></li>
|
|
||||||
<?rb else ?>
|
|
||||||
<li><a href="#{ i[:url] }">#{ i[:name] }</a></li>
|
|
||||||
<?rb end ?>
|
|
||||||
<?rb end ?>
|
|
||||||
</ul>
|
|
||||||
<?rb else ?>
|
|
||||||
<p>The list is empty.</p>
|
|
||||||
<?rb end ?>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -36,7 +36,6 @@ Gem::Specification.new do |spec|
|
||||||
spec.add_development_dependency "rspec", ">= 3"
|
spec.add_development_dependency "rspec", ">= 3"
|
||||||
spec.add_development_dependency "sass"
|
spec.add_development_dependency "sass"
|
||||||
spec.add_development_dependency "slim"
|
spec.add_development_dependency "slim"
|
||||||
spec.add_development_dependency "tenjin"
|
|
||||||
spec.add_development_dependency "therubyracer"
|
spec.add_development_dependency "therubyracer"
|
||||||
spec.add_development_dependency "unindent"
|
spec.add_development_dependency "unindent"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue