Problems? Is your data what you think it is? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
First off, I luv 'pack/unpack', but it may not always be the most efficient. There are several way to determine performance, but an excellent tool to use is 'NYTprof'. I had a Perl script that I couldn't improve the performance no matter what I did. I profiled it and found that my problem was calling 'pack/unpack' too often. On a run of 50,000 records, the script was calling 'pack/unpack' over 5,000,000 times. The 'pack/unpack' was in a tight loop, working on 32 byte substrings of a 4K string. What came to the rescue was 'substr'. Using the 4 parameter as In this situation, 'substr' just moves the pointer to the new beginning of the string, and was more efficient. I then used the 3 parameter non-destructive 'substr' to see it this was the substring I wanted, and then call 'pack/unpack'. Immediately, I saw a 300% improvement in performance and 'pack/unpack' was now called about 150,000 times. Perl has lots of powerful tools! Good Luck! "Well done is better than well said." - Benjamin Franklin In reply to Re: How do unpack templates work
by flexvault
|
|