ingydotnet / yaml-libyaml-pm

Perl Binding to libyaml
http://search.cpan.org/dist/YAML-LibYAML/
33 stars 37 forks source link

YAML::Syck still outperforms YAML::XS #62

Open toddr opened 7 years ago

toddr commented 7 years ago

Results first:

$>perl bench.pl 
YAML::Syck 1.29: Ran 21 iterations (0 outliers).
YAML::Syck 1.29: Rounded run time per iteration: 1.3650e-01 +/- 2.9e-04 (0.2%)
YAML::XS 0.63: Ran 21 iterations (1 outliers).
YAML::XS 0.63: Rounded run time per iteration: 2.4036e-01 +/- 1.8e-04 (0.1%)

The code:


$>cat bench.pl 
use strict;
use warnings;
use Dumbbench;
use YAML::XS ();
use YAML::Syck ();
my $bench = Dumbbench->new(
    target_rel_precision => 0.005, # seek ~0.5%
    initial_runs         => 20,    # the higher the more reliable
);
my $obj = YAML::Syck::LoadFile("ssl.yaml");
$bench->add_instances(
    Dumbbench::Instance::PerlSub->new(name => 'YAML::Syck ' . $YAML::Syck::VERSION, code => sub { my $string = YAML::Syck::Dump($obj); }),
    Dumbbench::Instance::PerlSub->new(name => 'YAML::XS ' . $YAML::XS::VERSION, code => sub { my $string = YAML::XS::Dump($obj); }),
);
$bench->run;
$bench->report;
toddr commented 7 years ago

Data file attached:

ssl.yaml.txt

perlpunk commented 7 years ago

Ah, I see, thanks. I thought you were talking about Load. I haven't benchmarked Dump myself yet.