Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix benchmark script

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