CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Perl code optimization

 



ssampath123
Novice

Nov 2, 2011, 10:31 AM

Post #1 of 6 (1855 views)
Perl code optimization Can't Post

Hi,

I have created a comparison algorithm that will compare for difference between two files and output them. I work with large files with easily 10000+ lines. Initially, I used 1 while loop for filehandle for first file and the tie:File module to place the lines of the second file into array. Now I use the tie module for the first file too. I compare the files by initially sorting the lines based on key columns provided by user, then ignore certain columns provided by users.

My comparison works fine but, it take atleast 1 hour to finish. performance is very critical and I would like to minize that time.

I am pretty sure the call to the file is slowing down the program.

I was wondering if you guys can give suggestions on how I can improve the performance??

\Thanks!


FishMonger
Veteran / Moderator

Nov 2, 2011, 12:18 PM

Post #2 of 6 (1845 views)
Re: [ssampath123] Perl code optimization [In reply to] Can't Post

Use the Devel::NYTProf module to profile your script.
http://search.cpan.org/~timb/Devel-NYTProf-4.06/lib/Devel/NYTProf.pm

And the Benchmark module to compare different methods of doing each section.
http://search.cpan.org/~flora/perl-5.14.2/lib/Benchmark.pm


(This post was edited by FishMonger on Nov 2, 2011, 12:20 PM)


ssampath123
Novice

Nov 3, 2011, 8:19 AM

Post #3 of 6 (1797 views)
Re: [FishMonger] Perl code optimization [In reply to] Can't Post

hmm..im trying to profile my code.

I generated the tmon.out file

But when I try to run dprofpp command my unix terminal does not recognize the command. Am not sure what I am missing.


FishMonger
Veteran / Moderator

Nov 3, 2011, 8:36 AM

Post #4 of 6 (1792 views)
Re: [ssampath123] Perl code optimization [In reply to] Can't Post

Sounds like you didn't install dprofpp.

Did you use the depreciated Devel::DProf module to create the tmon.out file or the Devel::NYTProf module I suggested?

If you used Devel::NYTProf, then use its nytprofhtml command to generate the html reports.


ssampath123
Novice

Nov 3, 2011, 8:50 AM

Post #5 of 6 (1790 views)
Re: [FishMonger] Perl code optimization [In reply to] Can't Post

hmm...I used Dprof because I did not have the NYTProf module in Devel. I also do not have authorities to place it there. Is there any workaround to this?


FishMonger
Veteran / Moderator

Nov 3, 2011, 9:14 AM

Post #6 of 6 (1789 views)
Re: [ssampath123] Perl code optimization [In reply to] Can't Post

You can install the module to any location where you have write permission.

http://www.perlmonks.org/?node_id=128077
http://www.perl.com/pub/2002/04/10/mod_perl.html
http://servers.digitaldaze.com/extensions/perl/modules.html

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives