in reply to need to optimize my sub routine

You have used Devel::DProf, that's a good start. It has told you that most of the time is spent in main(). Unfortunately, and perhaps not unsurprisingly, main also appears to contain most of the code.

To obtain a more fine-grained picture of what is going on, you need to employ line-based profiling. For this, Devel::SmallProf will come in very handy. This will give you an idea of which lines are being hit hard, and which lines are expensive to run. This may give you sufficient information to reconsider your algorithm.

• another intruder with the mooring in the heart of the Perl

Replies are listed 'Best First'.
Re^2: need to optimize my sub routine
by convenientstore (Pilgrim) on Feb 20, 2008 at 02:04 UTC
    thank you pc88mxer and hipowls
    I have moved it out of the loop and shaved off about close to 30 sec!!
    grinder, I will also check your suggestion
    All in all, I will just go back to developer and tell him that it might be just faster to run it on faster hardware
    real 2m45.342s user 2m43.562s sys 0m1.684s sub main { my $csv = Text::CSV_XS->new; for (@files) { open ( NOW , "$directory/$_" ) || die "you suck\n"; while (<NOW>) { my (%rec,%HoH); my $p; chomp; $t_counter++; $csv->parse($_); my @fields = $csv->fields;