Fix benchmark script
This commit is contained in:
parent
8ccc477c41
commit
47dc5d706a
|
@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
||||||
spec.add_development_dependency 'rails'
|
spec.add_development_dependency 'rails'
|
||||||
spec.add_development_dependency 'ruby_parser'
|
spec.add_development_dependency 'ruby_parser'
|
||||||
spec.add_development_dependency 'ruby-prof'
|
spec.add_development_dependency 'ruby-prof'
|
||||||
|
spec.add_development_dependency 'rbench'
|
||||||
|
|
||||||
spec.description = <<-END
|
spec.description = <<-END
|
||||||
Haml (HTML Abstraction Markup Language) is a layer on top of HTML or XML that's
|
Haml (HTML Abstraction Markup Language) is a layer on top of HTML or XML that's
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
require "rubygems"
|
||||||
|
require "bundler/setup"
|
||||||
|
require "haml"
|
||||||
|
require "rbench"
|
||||||
|
|
||||||
times = (ARGV.first || 1000).to_i
|
times = (ARGV.first || 1000).to_i
|
||||||
|
|
||||||
if times == 0 # Invalid parameter
|
if times == 0 # Invalid parameter
|
||||||
|
@ -8,8 +13,6 @@ END
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
require File.dirname(__FILE__) + '/../lib/haml'
|
|
||||||
require File.dirname(__FILE__) + '/linked_rails'
|
|
||||||
%w[rubygems erb erubis active_support action_controller
|
%w[rubygems erb erubis active_support action_controller
|
||||||
action_view action_pack haml/template rbench].each {|dep| require(dep)}
|
action_view action_pack haml/template rbench].each {|dep| require(dep)}
|
||||||
|
|
||||||
|
@ -53,36 +56,31 @@ RBench.run(times) do
|
||||||
end
|
end
|
||||||
|
|
||||||
report "ActionView" do
|
report "ActionView" do
|
||||||
@base = view
|
|
||||||
|
|
||||||
@base.unmemoize_all
|
|
||||||
Haml::Template.options[:ugly] = false
|
Haml::Template.options[:ugly] = false
|
||||||
# To cache the template
|
# To cache the template
|
||||||
render @base, 'haml/templates/standard'
|
render view, 'templates/standard'
|
||||||
render @base, 'haml/erb/standard'
|
render view, 'erb/standard'
|
||||||
|
|
||||||
haml { render @base, 'haml/templates/standard' }
|
haml { render view, 'templates/standard' }
|
||||||
erb { render @base, 'haml/erb/standard' }
|
erb { render view, 'erb/standard' }
|
||||||
|
|
||||||
Haml::Template.options[:ugly] = true
|
Haml::Template.options[:ugly] = true
|
||||||
render @base, 'haml/templates/standard_ugly'
|
render view, 'templates/standard_ugly'
|
||||||
haml_ugly { render @base, 'haml/templates/standard_ugly' }
|
haml_ugly { render view, 'templates/standard_ugly' }
|
||||||
end
|
end
|
||||||
|
|
||||||
report "ActionView with deep partials" do
|
report "ActionView with deep partials" do
|
||||||
@base = view
|
|
||||||
|
|
||||||
@base.unmemoize_all
|
|
||||||
Haml::Template.options[:ugly] = false
|
Haml::Template.options[:ugly] = false
|
||||||
# To cache the template
|
# To cache the template
|
||||||
render @base, 'haml/templates/action_view'
|
render view, 'templates/action_view'
|
||||||
render @base, 'haml/erb/action_view'
|
render view, 'erb/action_view'
|
||||||
|
|
||||||
haml { render @base, 'haml/templates/action_view' }
|
haml { render view, 'templates/action_view' }
|
||||||
erb { render @base, 'haml/erb/action_view' }
|
erb { render view, 'erb/action_view' }
|
||||||
|
|
||||||
Haml::Template.options[:ugly] = true
|
Haml::Template.options[:ugly] = true
|
||||||
render @base, 'haml/templates/action_view_ugly'
|
render view, 'templates/action_view_ugly'
|
||||||
haml_ugly { render @base, 'haml/templates/action_view_ugly' }
|
haml_ugly { render view, 'templates/action_view_ugly' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<li>
|
<li>
|
||||||
<strong>Partial:</strong>
|
<strong>Partial:</strong>
|
||||||
<% @nesting = 5 %>
|
<% @nesting = 5 %>
|
||||||
<%= render :partial => 'haml/erb/av_partial_2' %>
|
<%= render :partial => 'erb/av_partial_2' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
<h3>This is a crazy deep-nested partial.</h3>
|
<h3>This is a crazy deep-nested partial.</h3>
|
||||||
<p>Nesting level <%= @nesting %></p>
|
<p>Nesting level <%= @nesting %></p>
|
||||||
<% if @nesting > 0 %>
|
<% if @nesting > 0 %>
|
||||||
<%= render :partial => 'haml/erb/av_partial_2' %>
|
<%= render :partial => 'erb/av_partial_2' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
It's only used for benchmarking.
|
It's only used for benchmarking.
|
||||||
</h1>
|
</h1>
|
||||||
<div class="crazy_partials">
|
<div class="crazy_partials">
|
||||||
<%= render :partial => 'haml/erb/av_partial_1' %>
|
<%= render :partial => 'erb/av_partial_1' %>
|
||||||
</div>
|
</div>
|
||||||
<!-- You're In my house now! -->
|
<!-- You're In my house now! -->
|
||||||
<div class='header'>
|
<div class='header'>
|
||||||
|
|
|
@ -6,4 +6,4 @@
|
||||||
%li
|
%li
|
||||||
%strong Partial:
|
%strong Partial:
|
||||||
- @nesting = 5
|
- @nesting = 5
|
||||||
= render :partial => 'haml/templates/av_partial_2'
|
= render :partial => 'templates/av_partial_2'
|
|
@ -6,4 +6,4 @@
|
||||||
%li
|
%li
|
||||||
%strong Partial:
|
%strong Partial:
|
||||||
- @nesting = 5
|
- @nesting = 5
|
||||||
= render :partial => 'haml/templates/av_partial_2_ugly'
|
= render :partial => 'templates/av_partial_2_ugly'
|
|
@ -2,4 +2,4 @@
|
||||||
.partial{:level => @nesting}
|
.partial{:level => @nesting}
|
||||||
%h3 This is a crazy deep-nested partial.
|
%h3 This is a crazy deep-nested partial.
|
||||||
%p== Nesting level #{@nesting}
|
%p== Nesting level #{@nesting}
|
||||||
= render :partial => 'haml/templates/av_partial_2' if @nesting > 0
|
= render :partial => 'templates/av_partial_2' if @nesting > 0
|
|
@ -2,4 +2,4 @@
|
||||||
.partial{:level => @nesting}
|
.partial{:level => @nesting}
|
||||||
%h3 This is a crazy deep-nested partial.
|
%h3 This is a crazy deep-nested partial.
|
||||||
%p== Nesting level #{@nesting}
|
%p== Nesting level #{@nesting}
|
||||||
= render :partial => 'haml/templates/av_partial_2_ugly' if @nesting > 0
|
= render :partial => 'templates/av_partial_2_ugly' if @nesting > 0
|
|
@ -8,7 +8,7 @@
|
||||||
This is very much like the standard template,
|
This is very much like the standard template,
|
||||||
except that it has some ActionView-specific stuff.
|
except that it has some ActionView-specific stuff.
|
||||||
It's only used for benchmarking.
|
It's only used for benchmarking.
|
||||||
.crazy_partials= render :partial => 'haml/templates/av_partial_1'
|
.crazy_partials= render :partial => 'templates/av_partial_1'
|
||||||
/ You're In my house now!
|
/ You're In my house now!
|
||||||
.header
|
.header
|
||||||
Yes, ladies and gentileman. He is just that egotistical.
|
Yes, ladies and gentileman. He is just that egotistical.
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
This is very much like the standard template,
|
This is very much like the standard template,
|
||||||
except that it has some ActionView-specific stuff.
|
except that it has some ActionView-specific stuff.
|
||||||
It's only used for benchmarking.
|
It's only used for benchmarking.
|
||||||
.crazy_partials= render :partial => 'haml/templates/av_partial_1_ugly'
|
.crazy_partials= render :partial => 'templates/av_partial_1_ugly'
|
||||||
/ You're In my house now!
|
/ You're In my house now!
|
||||||
.header
|
.header
|
||||||
Yes, ladies and gentileman. He is just that egotistical.
|
Yes, ladies and gentileman. He is just that egotistical.
|
||||||
|
|
Loading…
Reference in New Issue