Created
June 23, 2014 02:02
-
-
Save jadeallenx/17dc08b635967c144176 to your computer and use it in GitHub Desktop.
Do some primitive benchmarking on JSON serialization.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Benchmark qw(:all); | |
use Data::Random::Structure; | |
use Data::Dumper; | |
use JSON::PP (); | |
use JSON::XS (); | |
my $g = Data::Random::Structure->new(); | |
my $ref = $g->generate(); | |
warn Dumper $ref; | |
my %tests = ( | |
'PP' => sub { | |
JSON::PP->new->utf8->encode($ref); | |
}, | |
'XS' => sub { | |
JSON::XS->new->utf8->encode($ref); | |
}, | |
); | |
cmpthese(50000, \%tests); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment