$>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;
Results first:
The code: