Keep It Simple, Stupid | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Having profiled you code line by line two different ways, it seems that almost all of the time is spent performing IO. Either reading from or writing to files. The only executable line that shows any significant cpu ot elapsed time usage is the the line 92: my @array = split(" ", $in); Which I don't see any easy way to optimise. Of course, the IO charecteristics of my system may be significantly different from the system you are running on, though I notice you are on a Win32 sytem too, so it shouldn't be so different. As for why the FORTRAN program is so much faster, assuming that it is doing the same processing,IO and running on the same hardware (which is an open question?), then my best guess is that the FORTRAN IO uses larger buffers and asynchronous reads and writes. I know of at least one PC-based FORTRAN compiler that does this. It is possible to use threads and other techniques to acheive this using perl without radically altering the structure of your existing program, but it isn't trivial to do. Whether you would come close to getting the kind of speed up you would need is very speculative. This is the output from using Devel::SmallProf on your code. I've massaged the output to just show the significant lines in decreasing order of cpu usage.
I noticed a couple of errors in your code, but these have been noted above. One question? Are you guys paid by the keystoke? :^) Those have to be the longest variable names I've come across in a while. Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller In reply to Re: Fast reading and processing from a text file - Perl vs. FORTRAN
by BrowserUk
|
|