A few points:
My machine is Win2k on P4 1800 GHz and 256 MB of memory.
The file loading takes 22 seconds. The first search method (loop with substr takes 2 minutes), the second takes 1 second. What concerns me though, is that neither reported that the sequence "wasn't found" in a completely random binary file (the probability of 0xff x 16 to appear is 2E-128, quite unlikely).
I wonder about the speed differences... what makes my program run slower on a far stronger PC ? Bad Perl implementation (Activeperl 5.6) ?
Also, could you please elaborate on the use of the following line:
$/ = \(100*1024*1024)
I only used $/ as in "undef $/" to read a file wholly, or to set a record separator. What does your line do ?
----------- Update ------------
I think I figured out the performance problem. My PC usually runs at 190 MB memory usage, which means that the 100MB slurped threw it into the "virtual realm", which naturally downgrades performance.
Now I read as follows:
And then just compare to the wanted value. The whole process (which now combines reading & testing) takes 28 seconds.until (eof(FH)) ... read(FH, $val, 128); ...
By the way, I was wrong about other thing. You first method (with substr) works correctly - it doesn't find the string. The second method (with index) seems to do find a string, or at least it thinks so, which is probably wrong (look at your test output, it's obvious there too)
In reply to Re: Re: is perl the best tool for this job?(emphatically Yes!)
by spurperl
in thread is perl the best tool for this job ?
by spurperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |