File: encode.pl

package info (click to toggle)
libgeo-hash-xs-perl 0.00015-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 412 kB
  • sloc: perl: 1,981; ansic: 55; makefile: 3
file content (32 lines) | stat: -rw-r--r-- 681 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use strict;
use Geo::Hash ;
use Geo::Hash::XS;
use Benchmark qw(:all);

my $lat   = 50;
my $lon   = 30;
my $gh_pp = Geo::Hash->new();
my $gh_xs = Geo::Hash::XS->new();


print "Geo::Hash: $Geo::Hash::VERSION\n",
    "Geo::Hash::XS: $Geo::Hash::XS::VERSION\n\n";

for my $p (0, 5, 10, 20, 30) {
    my @args = ($lat, $lon);
    if ($p != 0) {
        push @args, $p;
        print STDERR "precision = $p...\n";
    } else {
        print STDERR "precision = auto...\n";
    }
    cmpthese( -2, {
        perl => sub {
            my $hash = $gh_pp->encode( @args );
        },
        xs => sub {
            my $hash = $gh_xs->encode( @args );
        }
    });
    print "\n\n";
}