Sha256: 1aa243d06e2ca1a33b4f4b1e3cc6b1c670155700274fde420d19025eb5aea5e5

Contents?: true

Size: 1.43 KB

Versions: 56

Compression:

Stored size: 1.43 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.view_paths = [ 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

56 entries across 56 versions & 1 rubygems

Version Path
backlog-0.0.0 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.0.1 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.0.2 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.0.5 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.0.4 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.1.0 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.1.1 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.1.2 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.2.0 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.2.1 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.3.0 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.3.1 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.3.3 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.3.2 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.3.4 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.3.5 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.3.6 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.3.8 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.3.7 vendor/rails/actionpack/examples/benchmark.rb
backlog-0.3.9 vendor/rails/actionpack/examples/benchmark.rb