in reply to How smart is 'seek $fh, $pos, 0'?
Absolute seeks (forward) are (nearly twice) faster than relative seeks from the current position. (Maybe it has to do a tell to find out the current position before relative seeks?)
Backward seeks from the end are 3 times slower than forward seeks.
open O, '+<:raw', '1GBx8.bin' or die $!;; seek O, 0, 0; $t=time; seek O, $_*1000, 0 for 0 .. 8589934; print time +-$t;; 7.61572408676147 seek O, 0, 0; $t=time; seek O, 1000, 1 for 0 .. 8589934; print time-$t +;; 11.6447620391846 seek O, 0, 2; $t=time; seek O, -1000, 1 for 0 .. 8589934; print time-$ +t;; 11.6476919651031 seek O, 0, 2; $t=time; seek O, $_*-1000, 2 for 0 .. 8589934; print tim +e-$t;; 23.074695110321
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How smart is 'seek $fh, $pos, 0'?
by choroba (Cardinal) on May 27, 2015 at 13:18 UTC | |
by BrowserUk (Patriarch) on May 27, 2015 at 14:14 UTC | |
by BrowserUk (Patriarch) on May 27, 2015 at 15:20 UTC | |
|
Re^2: How smart is 'seek $fh, $pos, 0'?
by MidLifeXis (Monsignor) on May 27, 2015 at 14:20 UTC | |
by BrowserUk (Patriarch) on May 27, 2015 at 14:35 UTC | |
by MidLifeXis (Monsignor) on May 27, 2015 at 15:40 UTC | |
|
Re^2: How smart is 'seek $fh, $pos, 0'?
by Monk::Thomas (Friar) on May 27, 2015 at 13:29 UTC |