aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-08-11 16:49:27 -0700
committerYehuda Katz <wycats@gmail.com>2009-08-11 16:49:27 -0700
commit27e880729eeb058583b79ccf84a7577c434addfd (patch)
tree88125880559f1609f23ff42f8fb991879dae0259 /actionpack
parentccd1c5e521c020118b5bcfeb4cd5a651997b6806 (diff)
downloadrails-27e880729eeb058583b79ccf84a7577c434addfd.tar.gz
rails-27e880729eeb058583b79ccf84a7577c434addfd.tar.bz2
rails-27e880729eeb058583b79ccf84a7577c434addfd.zip
Made benchmarks submodule so it's easier to keep in sync
Diffstat (limited to 'actionpack')
m---------actionpack/examples0
-rw-r--r--actionpack/examples/minimal.rb132
-rw-r--r--actionpack/examples/very_simple.rb50
-rw-r--r--actionpack/examples/views/_collection.erb1
-rw-r--r--actionpack/examples/views/_hello.erb1
-rw-r--r--actionpack/examples/views/_hundred_partials.erb12
-rw-r--r--actionpack/examples/views/_many_partials.erb10
-rw-r--r--actionpack/examples/views/_partial.erb10
-rw-r--r--actionpack/examples/views/layouts/alt.html.erb1
-rw-r--r--actionpack/examples/views/layouts/kaigi.html.erb1
-rw-r--r--actionpack/examples/views/template.html.erb1
11 files changed, 0 insertions, 219 deletions
diff --git a/actionpack/examples b/actionpack/examples
new file mode 160000
+Subproject 4e1327f06da6df1a1981d69c04e8d6463b38a4c
diff --git a/actionpack/examples/minimal.rb b/actionpack/examples/minimal.rb
deleted file mode 100644
index 62b71de2cb..0000000000
--- a/actionpack/examples/minimal.rb
+++ /dev/null
@@ -1,132 +0,0 @@
-# Pass NEW=1 to run with the new Base
-ENV['RAILS_ENV'] ||= 'production'
-ENV['NO_RELOAD'] ||= '1'
-
-$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
-$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../activesupport/lib"
-require 'action_controller'
-require 'action_controller/new_base' if ENV['NEW']
-require 'action_view'
-require 'benchmark'
-
-class Runner
- def initialize(app, output)
- @app, @output = app, output
- end
-
- def puts(*)
- super if @output
- end
-
- def call(env)
- env['n'].to_i.times { @app.call(env) }
- @app.call(env).tap { |response| report(env, response) }
- end
-
- def report(env, response)
- return unless ENV["DEBUG"]
- out = env['rack.errors']
- out.puts response[0], response[1].to_yaml, '---'
- response[2].each { |part| out.puts part }
- out.puts '---'
- end
-
- def self.puts(*)
- super if @output
- end
-
- def self.run(app, n, label, output = true)
- @output = output
- puts label, '=' * label.size if label
- env = Rack::MockRequest.env_for("/").merge('n' => n, 'rack.input' => StringIO.new(''), 'rack.errors' => $stdout)
- t = Benchmark.realtime { new(app, output).call(env) }
- puts "%d ms / %d req = %.1f usec/req" % [10**3 * t, n, 10**6 * t / n]
- puts
- end
-end
-
-
-N = (ENV['N'] || 1000).to_i
-
-module ActionController::Rails2Compatibility
- instance_methods.each do |name|
- remove_method name
- end
-end
-
-class BasePostController < ActionController::Base
- append_view_path "#{File.dirname(__FILE__)}/views"
-
- def overhead
- self.response_body = ''
- end
-
- def index
- render :text => ''
- end
-
- def partial
- render :partial => "/partial"
- end
-
- def many_partials
- render :partial => "/many_partials"
- end
-
- def hundred_partials
- render :partial => "/hundred_partials"
- end
-
- def partial_collection
- render :partial => "/collection", :collection => [1,2,3,4,5,6,7,8,9,10]
- end
-
- def large_collection
- render :partial => "/collection", :collection => (1...1000).to_a
- end
-
- def show_template
- render :template => "template"
- end
-end
-
-OK = [200, {}, []]
-MetalPostController = lambda { OK }
-
-class HttpPostController < ActionController::Metal
- def index
- self.response_body = ''
- end
-end
-
-ActionController::Base.use_accept_header = false
-
-unless ENV["PROFILE"]
- Runner.run(BasePostController.action(:overhead), 1, 'overhead', false)
- Runner.run(BasePostController.action(:index), 1, 'index', false)
- Runner.run(BasePostController.action(:show_template), 1, 'template', false)
- Runner.run(BasePostController.action(:partial), 1, 'partial', false)
- Runner.run(BasePostController.action(:many_partials), 1, 'many_partials', false)
- Runner.run(BasePostController.action(:partial_collection), 1, 'collection', false)
- Runner.run(BasePostController.action(:hundred_partials), 1, 'hundred_partials', false)
- Runner.run(BasePostController.action(:large_collection), 1, 'large_collection', false)
-
- (ENV["M"] || 1).to_i.times do
- Runner.run(BasePostController.action(:overhead), N, 'overhead')
- Runner.run(BasePostController.action(:index), N, 'index')
- Runner.run(BasePostController.action(:show_template), N, 'template')
- Runner.run(BasePostController.action(:partial), N, 'partial')
- Runner.run(BasePostController.action(:many_partials), N, 'many_partials')
- Runner.run(BasePostController.action(:partial_collection), N, 'collection')
- Runner.run(BasePostController.action(:hundred_partials), N, 'hundred_partials')
- Runner.run(BasePostController.action(:large_collection), N, 'large_collection')
- end
-else
- Runner.run(BasePostController.action(ENV["PROFILE"].to_sym), 1, ENV["PROFILE"])
- require "ruby-prof"
- RubyProf.start
- Runner.run(BasePostController.action(ENV["PROFILE"].to_sym), N, ENV["PROFILE"])
- result = RubyProf.stop
- printer = RubyProf::CallStackPrinter.new(result)
- printer.print(File.open("output.html", "w"))
-end \ No newline at end of file
diff --git a/actionpack/examples/very_simple.rb b/actionpack/examples/very_simple.rb
deleted file mode 100644
index 6714185172..0000000000
--- a/actionpack/examples/very_simple.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-$:.push "rails/activesupport/lib"
-$:.push "rails/actionpack/lib"
-
-require "action_controller"
-
-class Kaigi < ActionController::Metal
- include AbstractController::Callbacks
- include ActionController::RackConvenience
- include ActionController::RenderingController
- include ActionController::Layouts
- include ActionView::Context
-
- before_filter :set_name
- append_view_path "views"
-
- def view_context
- self
- end
-
- def controller
- self
- end
-
- DEFAULT_LAYOUT = Object.new.tap {|l| def l.render(*) yield end }
-
- def render_template(template, layout = DEFAULT_LAYOUT, options = {}, partial = false)
- ret = template.render(self, {})
- layout.render(self, {}) { ret }
- end
-
- def index
- render :template => "template"
- end
-
- def alt
- render :template => "template", :layout => "alt"
- end
-
- private
- def set_name
- @name = params[:name]
- end
-end
-
-app = Rack::Builder.new do
- map("/kaigi") { run Kaigi.action(:index) }
- map("/kaigi/alt") { run Kaigi.action(:alt) }
-end.to_app
-
-Rack::Handler::Mongrel.run app, :Port => 3000
diff --git a/actionpack/examples/views/_collection.erb b/actionpack/examples/views/_collection.erb
deleted file mode 100644
index bcfe958e2c..0000000000
--- a/actionpack/examples/views/_collection.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= collection %> \ No newline at end of file
diff --git a/actionpack/examples/views/_hello.erb b/actionpack/examples/views/_hello.erb
deleted file mode 100644
index 5ab2f8a432..0000000000
--- a/actionpack/examples/views/_hello.erb
+++ /dev/null
@@ -1 +0,0 @@
-Hello \ No newline at end of file
diff --git a/actionpack/examples/views/_hundred_partials.erb b/actionpack/examples/views/_hundred_partials.erb
deleted file mode 100644
index 15e99c1b68..0000000000
--- a/actionpack/examples/views/_hundred_partials.erb
+++ /dev/null
@@ -1,12 +0,0 @@
-<% 10.times do %>
- <%= render :partial => '/hello' %>
- <%= render :partial => '/hello' %>
- <%= render :partial => '/hello' %>
- <%= render :partial => '/hello' %>
- <%= render :partial => '/hello' %>
- <%= render :partial => '/hello' %>
- <%= render :partial => '/hello' %>
- <%= render :partial => '/hello' %>
- <%= render :partial => '/hello' %>
- <%= render :partial => '/hello' %>
-<% end %> \ No newline at end of file
diff --git a/actionpack/examples/views/_many_partials.erb b/actionpack/examples/views/_many_partials.erb
deleted file mode 100644
index 7e379d46f5..0000000000
--- a/actionpack/examples/views/_many_partials.erb
+++ /dev/null
@@ -1,10 +0,0 @@
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %> \ No newline at end of file
diff --git a/actionpack/examples/views/_partial.erb b/actionpack/examples/views/_partial.erb
deleted file mode 100644
index 3ca8e80b52..0000000000
--- a/actionpack/examples/views/_partial.erb
+++ /dev/null
@@ -1,10 +0,0 @@
-<%= "Hello" %>
-<%= "Hello" %>
-<%= "Hello" %>
-<%= "Hello" %>
-<%= "Hello" %>
-<%= "Hello" %>
-<%= "Hello" %>
-<%= "Hello" %>
-<%= "Hello" %>
-<%= "Hello" %>
diff --git a/actionpack/examples/views/layouts/alt.html.erb b/actionpack/examples/views/layouts/alt.html.erb
deleted file mode 100644
index c4816337a6..0000000000
--- a/actionpack/examples/views/layouts/alt.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-+ <%= yield %> + \ No newline at end of file
diff --git a/actionpack/examples/views/layouts/kaigi.html.erb b/actionpack/examples/views/layouts/kaigi.html.erb
deleted file mode 100644
index 274607a96a..0000000000
--- a/actionpack/examples/views/layouts/kaigi.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-Hello <%= yield %> Goodbye \ No newline at end of file
diff --git a/actionpack/examples/views/template.html.erb b/actionpack/examples/views/template.html.erb
deleted file mode 100644
index 5ab2f8a432..0000000000
--- a/actionpack/examples/views/template.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-Hello \ No newline at end of file