First generate 5,000 random numbers between 1 .. 5_000_000
$ cat gen_targets.pl #!/usr/bin/perl use strict; use warnings; my $file = $ARGV[0] || 'targets.txt'; open (OUTPUT, '>', $file) or die "Unable to open $file for writing : $ +!"; print OUTPUT int rand 5_000_000, "\n" for 1 .. 5_000;
Next, I just modified our 2 scripts as follows:
my $file = $ARGV[0] || 'targets.txt'; open (INPUT, '<', $file) or die "Unable to open $file for reading : $! +"; while ( <INPUT> ) { chomp; get_three( $_ ); # used your sub/calling convention }
And finally, the results:
$ time ./lr.pl real 1m0.706s user 1m0.416s sys 0m0.080s $ time ./fu.pl real 1m0.791s user 1m0.326s sys 0m0.220s
Cheers - L~R
In reply to Re^2: Triangle Numbers Revisited
by Limbic~Region
in thread Triangle Numbers Revisited
by Limbic~Region
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |