in reply to fastest way to compare numerical strings?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: fastest way to compare numerical strings?
by pc88mxer (Vicar) on Jun 30, 2008 at 23:56 UTC |