Stefan kaes would be the guy to talk to about this. While performance is / was a concern, it was not a reason for our lack of enthusiasm for component based web development. So a solution to any performance issues is unlikely to improve the perception of render_component in many people's eyes.
On 5/21/07, ara.t.howard <[EMAIL PROTECTED]> wrote: > > > hi- > > contrary to what i've read, i've been unable to show that components > are, in fact, slower than any other rendering process: > > ### a simple controller > cfp:~/src/ruby/componentry/componentry-0.0.0/sample/rails > cat app/ > controllers/bar_controller.rb > class BarController < ApplicationController > def initialize > @foo = 42 > @bar = 'forty-two' > end > def foo > render :text => @foo > end > def bar > render :text => @bar > end > def foobar > render :text => [EMAIL PROTECTED], @bar].inspect #=> [42, "forty-two"] > end > end > > ### benchmarking > cfp:~/src/ruby/componentry/componentry-0.0.0/sample/rails > ab -n 25 - > c 4 http://localhost:3000/bar/foobar|grep 'Requests' > Requests per second: 7.05 [#/sec] (mean) > > > ### another controller which uses the simple controller above via > component_for (see attached code) > cfp:~/src/ruby/componentry/componentry-0.0.0/sample/rails > cat app/ > controllers/foo_controller.rb > class FooController < ApplicationController > def foobar > # get a handle on, and parameterize, a bar controller > bar_controller = component_for(:controller => 'bar') do > @foo = 42 > @bar = 'forty-two' > end > > # call two actions on the bar controller, reusing the entire > model+view+controller > foo = bar_controller.content_for :action => 'foo' > bar = bar_controller.content_for :action => 'bar' > > render :text => [foo, bar].inspect #=> [42, "forty-two"] > end > end > > ### benchmarking > cfp:~/src/ruby/componentry/componentry-0.0.0/sample/rails > ab -n 25 - > c 4 http://localhost:3000/foo/foobar|grep 'Requests' > Requests per second: 6.79 [#/sec] (mean) > > > so this seems to indicate that the above two routes, with and without > components, are essentially the same. does anyone have code showing > that they are significantly slower? my reading of the rails source > doesn't show any significant work being done when components are > used, many objects are dup'd when possible, so this makes sense to > me. nonetheless the net is awash with people claiming this is not true. > > ps. above is using lighttpd, perhaps mongrel would have issues with > concurrency? > > kind regards. > > -a > -- > we can deny everything, except that we have the possibility of being > better. simply reflect on that. > h.h. the 14th dalai lama > > > > > > > -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
