Sha256: 588c1219e3d9c52590ca792101a8ed4825c3237b663fbc1499ccfab723b57527

Contents?: true

Size: 1.42 KB

Versions: 51

Compression:

Stored size: 1.42 KB

Contents

$:.unshift(File.dirname(__FILE__) + "/../lib")

require "action_controller"
require 'action_controller/test_process'

Person = Struct.new("Person", :name, :address, :age)

class BenchmarkController < ActionController::Base
  def message
    render_text "hello world"
  end

  def list
    @people = [ Person.new("David"), Person.new("Mary") ]
    render_template "hello: <% for person in @people %>Name: <%= person.name %><% end %>"
  end
  
  def form_helper
    @person = Person.new "david", "hyacintvej", 24
    render_template(
      "<% person = Person.new 'Mary', 'hyacintvej', 22 %> " +
      "change the name <%= text_field 'person', 'name' %> and  <%= text_field 'person', 'address' %> and <%= text_field 'person', 'age' %>"
    )
  end
end

#ActionController::Base.template_root = File.dirname(__FILE__)

require "benchmark"

RUNS = ARGV[0] ? ARGV[0].to_i : 50

require "profile" if ARGV[1]

runtime = Benchmark.measure {
  RUNS.times { BenchmarkController.process_test(ActionController::TestRequest.new({ "action" => "list" })) }
}

puts "List: #{RUNS / runtime.real}"


runtime = Benchmark.measure {
  RUNS.times { BenchmarkController.process_test(ActionController::TestRequest.new({ "action" => "message" })) }
}

puts "Message: #{RUNS / runtime.real}"

runtime = Benchmark.measure {
  RUNS.times { BenchmarkController.process_test(ActionController::TestRequest.new({ "action" => "form_helper" })) }
}

puts "Form helper: #{RUNS / runtime.real}"

Version data entries

51 entries across 51 versions & 5 rubygems

Version Path
devise_sociable-0.1.0 vendor/bundle/gems/actionpack-1.4.0/examples/benchmark.rb
jstorimer-deep-test-2.0.0 sample_rails_project/vendor/rails/actionpack/examples/benchmark.rb
jstorimer-deep-test-1.4.0 sample_rails_project/vendor/rails/actionpack/examples/benchmark.rb
jstorimer-deep-test-1.3.0 sample_rails_project/vendor/rails/actionpack/examples/benchmark.rb
jstorimer-deep-test-1.2.0 sample_rails_project/vendor/rails/actionpack/examples/benchmark.rb
jstorimer-deep-test-1.1.0 sample_rails_project/vendor/rails/actionpack/examples/benchmark.rb
jstorimer-deep-test-1.0.0 sample_rails_project/vendor/rails/actionpack/examples/benchmark.rb
jstorimer-deep-test-0.2.0 sample_rails_project/vendor/rails/actionpack/examples/benchmark.rb
jstorimer-deep-test-0.1.0 sample_rails_project/vendor/rails/actionpack/examples/benchmark.rb
actionpack-0.9.5 examples/benchmark.rb
actionpack-0.9.0 examples/benchmark.rb
actionpack-1.0.1 examples/benchmark.rb
actionpack-1.1.0 examples/benchmark.rb
actionpack-1.0.0 examples/benchmark.rb
actionpack-1.11.2 examples/benchmark.rb
actionpack-1.11.1 examples/benchmark.rb
actionpack-1.12.0 examples/benchmark.rb
actionpack-1.11.0 examples/benchmark.rb
actionpack-1.10.1 examples/benchmark.rb
actionpack-1.10.2 examples/benchmark.rb