in reply to Using Devel::Profile output to know what to do next

I've never used Class::DBI, but a quick look shows that the code for Class::DBI::Column is very simple. It might be worth hacking it to cache the lower-case version of the classname to see if that makes a difference:

use overload '""' => sub { shift->{'name_lc'} }, fallback => 1; [...] sub new { my ($class, $name) = @_; return $class->SUPER::new( { name => $name, name_lc => lc($name), _groups => {}, placeholder => '?' } ); } sub name_lc { shift->{'name_lc'} }

That should save quite a chunk from the first two lines of your profile output:

%Time Sec. #calls sec/call F name 14.67 55.4872 2174052 0.000026 <anon>:...5.8.2/Class/DBI/Colu +mn.pm:37 9.55 36.1474 2178574 0.000017 Class::DBI::Column::name_lc

Be careful though if any other classes are inheriting from CDBI::Column - you'd need to check that this hack is compatible with their expectations. (I'd expect it to be ok though, as long as inheritors call their SUPER::new() to construct.)

Hugo

Replies are listed 'Best First'.
Re^2: Using Devel::Profile output to know what to do next
by perrin (Chancellor) on Jun 08, 2005 at 19:46 UTC
    Hang on, cowboy. You need to profile first to see if that method is taking up any real time or not. Your work could be totally pointless if the lowercase calls don't take a significant part of the actual wall time.

      Well whose two routines are taking 91 seconds of CPU time, so unless it's a multi-processor machine or a threaded application, they won't be taking less than 91 seconds of wall clock time.

      The numbers suggest total CPU time around 6.5 minutes; it would be useful to hear from the OP what the actual runtime is, but I'd expect my proposed hack to take more than a minute off it, replacing the 26+17 μs for 2.2 million calls with something more like the 10 μs of the accessor.

      But it is true - I'm used to profiling on a busy server, where useful wall clock times are hard-to-impossible to get, so mostly I concentrate on profiling to optimise CPU requirements, and use a combination of two other techniques for optimising the database side - the ever-popular "finger in the air" and "it hurts when I do this" techniques.

      Hugo