pmakholm (owner)

Forks

Revisions

gist: 130005 Download_button fork
public
Description:
Benchmark of serialization modules
Public Clone URL: git://gist.github.com/130005.git
Embed All Files: show embed
serialize.pl #
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/perl
 
# Originaly at:
# http://idisk.mac.com/christian.hansen/Public/perl/serialize.pl
# Updated by Peter Makholm, June 2009
# http://gist.github.com/130005
# - Added Data::Dumper and a current set of YAML/JSON modules
# - added tags for the -b option: :core, :yaml, :json
# Updated by Peter Makholm, October 2009
# - Moved main logic into Benchmark::Serialize
# see bottom of this script for benchmark results.
 
use strict;
use warnings;
 
use Getopt::Long;
use Benchmark::Serialize;
 
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;
 
Benchmark::Serialize::cmpthese($iterations, $structure, @benchmark);