Ran for default 3 CPU seconds:#!/usr/bin/perl -w use Benchmark ; use strict; my $count = shift || "-3" ; # set the test counter my @array = (); #load up an array of crap for ( my $i = 0; $i < 1000; $i++) { push @array, rand(256); } open NULL, "+/dev/null" or die "$!"; timethese ( $count, { 'join' => '&print_join', 'map' => '&print_map', 'field sep' => '&print_field' } ); # use join to print each array elemnet. sub print_join { print NULL join("\n", @array) ; } # use map to print each array elemnt, sub print_map { print NULL map{ $_ .= "\n"} @array ; } # use map to print each array elemnt, sub print_field { local $,="\n"; print NULL @array ; }
./time_print
Benchmark: running field sep, join, map, each for at least 3 CPU seconds...
field sep: 3 wallclock secs ( 3.15 usr + 0.00 sys = 3.15 CPU) @ 53645.71/s (n=168984)
join: 3 wallclock secs ( 3.05 usr + 0.01 sys = 3.06 CPU) @ 1256.86/s (n=3846)
map: 5 wallclock secs ( 4.56 usr + 0.04 sys = 4.60 CPU) @ 119.78/s (n=551)
looks like the field sepperator is the fastest with 53,645.71 /sec
In reply to Re: Request for further enlightenment
by yodabjorn
in thread Request for further enlightenment
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |