1) param is called often several times (in auto/end etc) 2) The question is not about params, but about accessors speed at all. If all acessors were XSAccessor for example (catalyst makes a lot of calls ->stack/action/dispatcher , etc internally during request), then your overall speed would be 600/s i think) 3) The question is also in approach to programming. Why someone writes $c->req->... $c->req->... $c->req->... If you know that $c->req is not a fast accessor why do you call it several times?
Is it hard to write ? my $req = $c->req; $req-> $req-> ... Maybe it is not the bottleneck, but how many places do we have like this that are "not a bottleneck" ? maybe the sum of all these "mini" mistakes is the bottleneck ? 2010/4/28 Андрей П. Ковбович <akovbov...@gmail.com>: > I was curious about what the big deal is raised, so spent a short test. > > *** Mojo *** (Alternative to Catalyst) > timethese(-1, { > param => sub { $tx->req->param('lang') }, > params => sub { $tx->req->params->param('lang') }, > }); > > Benchmark: running param, params for at least 1 CPU seconds... > param: 1 wallclock secs ( 1.07 usr + 0.00 sys = 1.07 CPU) @ > 13397.20/s (n=14335) > params: 1 wallclock secs ( 1.08 usr + 0.00 sys = 1.08 CPU) @ > 8295.37/s (n=8959) > > *** Cat *** > timethese(-1, { > param => sub { $c->req->param('lang') }, > params => sub { $c->req->params->{'lang'} }, > }); > > Benchmark: running param, params for at least 1 CPU seconds... > param: 1 wallclock secs ( 1.06 usr + 0.01 sys = 1.07 CPU) @ > 30918.69/s (n=33083) > params: 1 wallclock secs ( 1.07 usr + 0.01 sys = 1.08 CPU) @ > 79643.52/s (n=86015) > > My Сat app can handle about 400req/s, at the same time accessor's > access time is about 80K req/s, so if we imagine that we have not > made a single call to $req->param, in that case app will handle > 402req/s. Show me the idiot who will try to optimize all the code for > such trifles? > > _______________________________________________ > List: Catalyst@lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ > _______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/