Help for this page

Select Code to Download


  1. or download this
    while (<FILE>){};
    print "length = $.";
    
  2. or download this
    #!/usr/bin/perl
    
    ...
                    close(INFILE);
            }
    });
    
  3. or download this
    Benchmark: timing 100 iterations of chunk, line_by_line...
         chunk:  3 wallclock secs ( 1.58 usr +  0.70 sys =  2.28 CPU) @ 43
    +.80/s (n=100)
         line_by_line: 12 wallclock secs ( 9.54 usr +  0.72 sys = 10.27 CP
    +U) @  9.74/s (n=100)
    
  4. or download this
    open INFILE,'test.dat' or die "open: $!";
    my $count = 0;
    while (sysread(INFILE,$_,102400)) { $count += tr/\n//; }
    
  5. or download this
    /home/rhet/misc> ./testfcount.pl
    Benchmark: timing 100 iterations of chunk, line_by_line, sysread...
         chunk: 12 wallclock secs ( 8.00 usr +  3.52 sys = 11.53 CPU) @  8
    +.68/s (n=100)
         line_by_line: 154 wallclock secs (149.20 usr +  3.29 sys = 152.50
    + CPU) @  0.66/s (n=100)
         sysread:  6 wallclock secs ( 4.09 usr +  1.62 sys =  5.71 CPU) @ 
    +17.52/s (n=100)