in reply to Speed of Array Returns
this takes about 38 seconds, regardless of whether the array is passed by reference or by itself.#!/usr/bin/perl -w use strict; my $arraylength=1000; open(FOUT,">", "/dev/null"); my $now=time(); for (my $j=0; $j<100_000; ++$j) { # create a 1000 array my @array; for (my $i=0; $i<$arraylength; ++$i) { push(@array, rand()); } passed_array(\@array); sub passed_array { print FOUT $_[0]->[rand($arraylength)]; } } print "Time: ".(time()-$now)." seconds\n"; close(FOUT);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Speed of Array Returns
by chromatic (Archbishop) on Jan 31, 2010 at 06:59 UTC | |
by bobr (Monk) on Jan 31, 2010 at 11:26 UTC | |
by iaw4 (Monk) on Feb 03, 2010 at 13:44 UTC | |
by chromatic (Archbishop) on Feb 03, 2010 at 20:47 UTC |