Permalink
Browse files

Add simple render benchmark

  • Loading branch information...
1 parent e37da90 commit 542bb4e12693f44bf0a3548153b47f3dcde8bd0c @mneumann committed Jan 5, 2010
Showing with 34 additions and 0 deletions.
  1. +34 −0 test/bm_render.rb
View
@@ -0,0 +1,34 @@
+#
+# Render Wee::HelloWorld n-times
+#
+
+$LOAD_PATH.unshift "./lib"
+require 'rubygems'
+require 'wee'
+require 'rack'
+
+class Rack::Request
+ def put?; get? end
+end
+
+class Wee::HtmlWriter
+ def join
+ @port
+ end
+end
+
+root_component = Wee::HelloWorld.new
+Integer(ARGV[0] || raise).times do
+ r = Wee::Renderer.new
+ r.request = Wee::Request.new({'REQUEST_METHOD' => 'GET', 'SCRIPT_NAME' => 'blah', 'PATH_INFO' => 'blubb',
+ 'QUERY_STRING' => '_p=blah&_s=session'})
+ r.document = Wee::HtmlDocument.new
+ r.callbacks = Wee::Callbacks.new
+
+ begin
+ root_component.decoration.render_on(r)
+ ensure
+ r.close
+ end
+ Wee::GenericResponse.new(r.document.join)
+end

0 comments on commit 542bb4e

Please sign in to comment.