What gave you that impression?

my $f; open($f,'<',"bigfile") or die "Could not open file\n"; my $i; while ($i++<1000000) { seek($f,10,0); seek($f,3000,0); }

This script needs 1.2 seconds on my machine, for 2 millions seeks. Time for the loop without anything in it is 0.275 seconds, so we are at 460 nanoseconds per seek

my $f; open($f,'<',"bigfile") or die "Could not open file\n"; my $i; my $g; while ($i++<1000000) { seek($f,10,0); $g= <$f>; seek($f,3000,0); } print length $g,"\n";

This script additionally does one million reads of a 2 character string and runs 3 seconds. That means 1800 nanoseconds is the minimal time for a read (from cache obviously, if the data is on disk multiply that time by 1000 or more)


In reply to Re^3: Initialsing file pointer in the middle of a file. by jethro
in thread Initialsing file pointer in the middle of a file. by sabertooth

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.