Created
September 1, 2013 07:10
-
-
Save skopp/6402823 to your computer and use it in GitHub Desktop.
yaml serialize perl
This file contains 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/perl | |
use strict; | |
use warnings; | |
use Getopt::Long; | |
use Benchmark::Serialize qw( cmpthese ); | |
my @benchmark = (); # package names of benchmarks to run | |
my $iterations = -1; # integer | |
my $structure = { | |
array => [ 'a' .. 'j' ], | |
hash => { 'a' .. 'z' }, | |
string => 'x' x 200 | |
}; | |
Getopt::Long::Configure( 'bundling' ); | |
Getopt::Long::GetOptions( | |
'b|benchmark=s@' => \@benchmark, | |
'deflate!' => \$Benchmark::Serialize::benchmark_deflate, | |
'inflate!' => \$Benchmark::Serialize::benchmark_inflate, | |
'i|iterations=i' => \$iterations, | |
'o|output=s' => \$Benchmark::Serialize::output, | |
's|structure=s' => sub { | |
die "Structure option requires YAML.\n" | |
unless YAML->require; | |
$structure = YAML::LoadFile( $_[1] ); | |
} | |
) or exit 1; | |
@benchmark = ("all") unless @benchmark; | |
cmpthese($iterations, $structure, @benchmark); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment