From 47dc5d706a2e0cf0ade5e42e85dbdbc887df67b6 Mon Sep 17 00:00:00 2001 From: Norman Clarke Date: Fri, 27 Apr 2012 22:08:02 -0300 Subject: [PATCH] Fix benchmark script --- haml.gemspec | 1 + test/benchmark.rb | 36 ++++++++++++-------------- test/erb/_av_partial_1.erb | 2 +- test/erb/_av_partial_2.erb | 2 +- test/erb/action_view.erb | 2 +- test/templates/_av_partial_1.haml | 2 +- test/templates/_av_partial_1_ugly.haml | 2 +- test/templates/_av_partial_2.haml | 2 +- test/templates/_av_partial_2_ugly.haml | 2 +- test/templates/action_view.haml | 2 +- test/templates/action_view_ugly.haml | 2 +- 11 files changed, 27 insertions(+), 28 deletions(-) diff --git a/haml.gemspec b/haml.gemspec index 8e8a943d..451b5b99 100644 --- a/haml.gemspec +++ b/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 diff --git a/test/benchmark.rb b/test/benchmark.rb index 3b1b6b60..802999e2 100644 --- a/test/benchmark.rb +++ b/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 @@ END 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 @@ RBench.run(times) do 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 diff --git a/test/erb/_av_partial_1.erb b/test/erb/_av_partial_1.erb index 6cf41eb5..0c836a1a 100644 --- a/test/erb/_av_partial_1.erb +++ b/test/erb/_av_partial_1.erb @@ -6,7 +6,7 @@
  • Partial: <% @nesting = 5 %> - <%= render :partial => 'haml/erb/av_partial_2' %> + <%= render :partial => 'erb/av_partial_2' %> <% end %> diff --git a/test/erb/_av_partial_2.erb b/test/erb/_av_partial_2.erb index 017d9068..189d8588 100644 --- a/test/erb/_av_partial_2.erb +++ b/test/erb/_av_partial_2.erb @@ -3,6 +3,6 @@

    This is a crazy deep-nested partial.

    Nesting level <%= @nesting %>

    <% if @nesting > 0 %> - <%= render :partial => 'haml/erb/av_partial_2' %> + <%= render :partial => 'erb/av_partial_2' %> <% end %> diff --git a/test/erb/action_view.erb b/test/erb/action_view.erb index c81586f3..389ffe9d 100644 --- a/test/erb/action_view.erb +++ b/test/erb/action_view.erb @@ -11,7 +11,7 @@ It's only used for benchmarking.
    - <%= render :partial => 'haml/erb/av_partial_1' %> + <%= render :partial => 'erb/av_partial_1' %>
    diff --git a/test/templates/_av_partial_1.haml b/test/templates/_av_partial_1.haml index 7f47f726..b46502c2 100644 --- a/test/templates/_av_partial_1.haml +++ b/test/templates/_av_partial_1.haml @@ -6,4 +6,4 @@ %li %strong Partial: - @nesting = 5 - = render :partial => 'haml/templates/av_partial_2' \ No newline at end of file + = render :partial => 'templates/av_partial_2' \ No newline at end of file diff --git a/test/templates/_av_partial_1_ugly.haml b/test/templates/_av_partial_1_ugly.haml index 73e0ca7a..02aa9d0f 100644 --- a/test/templates/_av_partial_1_ugly.haml +++ b/test/templates/_av_partial_1_ugly.haml @@ -6,4 +6,4 @@ %li %strong Partial: - @nesting = 5 - = render :partial => 'haml/templates/av_partial_2_ugly' \ No newline at end of file + = render :partial => 'templates/av_partial_2_ugly' \ No newline at end of file diff --git a/test/templates/_av_partial_2.haml b/test/templates/_av_partial_2.haml index c8a313df..e7d2008f 100644 --- a/test/templates/_av_partial_2.haml +++ b/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 \ No newline at end of file + = render :partial => 'templates/av_partial_2' if @nesting > 0 \ No newline at end of file diff --git a/test/templates/_av_partial_2_ugly.haml b/test/templates/_av_partial_2_ugly.haml index 088a3c36..0b854fc9 100644 --- a/test/templates/_av_partial_2_ugly.haml +++ b/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 \ No newline at end of file + = render :partial => 'templates/av_partial_2_ugly' if @nesting > 0 \ No newline at end of file diff --git a/test/templates/action_view.haml b/test/templates/action_view.haml index 5b9fa04f..a90f423a 100644 --- a/test/templates/action_view.haml +++ b/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. diff --git a/test/templates/action_view_ugly.haml b/test/templates/action_view_ugly.haml index 5f0551ed..9e441a3d 100644 --- a/test/templates/action_view_ugly.haml +++ b/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.