You may get a very substantial improvement by only checking the longitudes if the latitudes are close. You can do this easily by splitting your if into two.
This runs in around 6 seconds here!
my @lat = map { rand( 180 ) - 90 } 1 .. 300_000; my @long = map { rand( 180 ) - 90 } 1 .. @lat; for my $lat ( 0 .. $#lat - 1 ) { if ( abs( $lat[$lat] - $lat[$lat+1] ) < 0.01 ) { for my $long ( 0 .. $#long - 1 ) { if ( abs( $long[$long] - $long[$long+1] ) < 0.01 ) { print "\$lat[$lat] = $lat[$lat] \$long[$long] = $long[ +$long]\n"; } } } }
Depending the spread of your points, this may give a very worthwhile improvement. But, if your points are all fairly close anyway, it won't be worthwhile.
In reply to Re: fastest way to compare numerical strings?
by FunkyMonk
in thread fastest way to compare numerical strings?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |