Using a 25k line dictionary file:
Benchmark: timing 100 iterations of array, assign, eof...
array: 40 wallclock secs (39.07 usr + 0.42 sys = 39.49 CPU) @ 2.53/s
(n=100)
assign: 20 wallclock secs (19.63 usr + 0.25 sys = 19.88 CPU) @ 5.03/s
(n=100)
eof: 19 wallclock secs (18.13 usr + 0.22 sys = 18.35 CPU) @ 5.45/s
(n=100)
#!/usr/bin/perl -w
use strict;
use Benchmark qw(:all);
my $count = shift || 100;
my $filename = shift || '/tmp/time.dat';
# Use Perl code in strings...
timethese($count, {
'eof' => 'openf; do{ $last_line = $_ if eof } while
<TMP>; closef;',
'array' => 'openf; @tmp = <TMP>; closef;',
'assign' => 'openf;do{ $last_line = $_ } while <TMP>;
closef;'
,
});
sub openf {
open(TMP, "$filename" ) or die "Cannot open $filename $!\n";
}
sub closef {
close TMP;
}
Andy Bach, Sys. Mangler
Internet: [EMAIL PROTECTED]
VOICE: (608) 261-5738 FAX 264-5932
Contrariwise," continued Tweedledee, "if it was so, it might be, and
if it were so, it would be; but as it isn't, it ain't. That's logic!"
-- Lewis Carroll, "Through the Looking Glass"
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs