Thread Seltsamer Effekt beim Dateieinlesen
(31 answers)
Opened by marky at 2011-09-26 11:25 Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 #!/usr/bin/perl use strict; use warnings; use Benchmark qw/cmpthese/; my $count = 100; cmpthese( $count, { 'line' => sub { my $f1; open( $f1, "< file" ); while ( my $l = <$f1> ) { push( my @ll, $l ); } close($f1); }, 'all' => sub { my $f1; open( $f1, "< file" ); my @ll = <$f1>; close($f1); } } ); bei einer 100 MB Textdatei mit 1_049_600 Zeilen: Windows 7 64bit, Perl 5.12.3: Debian 6 64bit, Perl 5.10.1: Ubuntu 10.04 auf VirtualBox: Interessant! Last edited: 2011-09-27 09:40:01 +0200 (CEST) |