[Rt-devel] [PATCH] Quote identifiers.
Jesse Vincent
jesse at bestpractical.com
Sat Jan 22 15:03:13 EST 2005
> Speed. See next benchmark
At the expense of clarity. I hate perl's method dispatch
performance. Will you update the patch with a comment about _why_
you're doing something that looks like it should be optimized away so
that someone else doesn't "fix" it?
> #!/usr/bin/perl -w
>
>
>
> use strict;
> use Benchmark qw(cmpthese);
> my $obj = new Dummy;
>
>
>
> cmpthese (-6, {
> 'with $dbh' => sub { $obj->w_cache(); },
> 'without $dbh' => sub { $obj->wo_cache() },
> });
>
>
>
> package Dummy;
>
>
>
> sub new { return bless { dbh => { foo => 'bar' } }, 'Dummy' }
> sub dbh { my $self = shift; return $self->{'dbh'} }
>
>
>
> sub w_cache {
> my $self = shift;
> my $dbh = $self->dbh;
> for(1..5) { my $x = $dbh->{foo} }
> }
> sub wo_cache {
> my $self = shift;
> for(1..5) {my $x = $self->dbh->{foo} }
> }
> Results:
> Rate without $dbh with $dbh
> without $dbh 43465/s -- -40%
> with $dbh 72127/s 66% --
>
> Something similar happens in sub Insert I call quote_identifier in map
> context for each column, also dbh sub in SB::Handle more complex then in
> benchmark.
>
> Similar situation in UpdateRecordValue.
>
--
More information about the Rt-devel
mailing list