~ubuntu-branches/debian/sid/libsereal-encoder-perl/sid

« back to all changes in this revision

Viewing changes to author_tools/bench.pl

  • Committer: Package Import Robot
  • Author(s): gregor herrmann
  • Date: 2014-06-06 13:17:09 UTC
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20140606131709-ek9vy22c4sh5jgjx
Tags: upstream-3.001
ImportĀ upstreamĀ versionĀ 3.001

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
my @rand = map rand, 1..1000;
66
66
our %data;
67
67
 
68
 
$data{$_}= make_data() for qw(sereal sereal_func dd1 dd2 ddl mp json_xs storable sereal_snappy cbor);
 
68
$data{$_}= make_data() for qw(sereal sereal_func dd1 dd2 ddl mp json_xs storable sereal_snappy sereal_zlib_fast sereal_zlib_small cbor);
69
69
 
70
70
our $enc = Sereal::Encoder->new(\%opt);
71
 
our $enc_snappy = Sereal::Encoder->new({%opt, snappy => 1});
 
71
our $enc_snappy = Sereal::Encoder->new({%opt, compress => Sereal::Encoder::SRL_SNAPPY});
 
72
our $enc_zlib_fast = Sereal::Encoder->new({%opt, compress => Sereal::Encoder::SRL_ZLIB, compress_level => 1, compress_threshold => 0});
 
73
our $enc_zlib_small = Sereal::Encoder->new({%opt, compress => Sereal::Encoder::SRL_ZLIB, compress_level => 10, compress_threshold => 0});
72
74
our $dec = Sereal::Decoder->new(\%opt);
73
75
 
74
 
our ($json_xs, $dd1, $dd2, $ddl, $sereal, $storable, $mp, $sereal_snappy, $cbor);
 
76
our ($json_xs, $dd1, $dd2, $ddl, $sereal, $storable, $mp, $sereal_snappy, $sereal_zlib_fast, $sereal_zlib_small, $cbor);
75
77
# do this first before any of the other dumpers "contaminate" the iv/pv issue
76
 
$sereal   = $enc->encode($data{sereal});
77
 
$sereal_snappy   = $enc_snappy->encode($data{sereal_snappy});
 
78
$sereal            = $enc->encode($data{sereal});
 
79
$sereal_snappy     = $enc_snappy->encode($data{sereal_snappy});
 
80
$sereal_zlib_fast  = $enc_zlib_fast->encode($data{sereal_zlib_fast});
 
81
$sereal_zlib_small = $enc_zlib_small->encode($data{sereal_zlib_small});
78
82
if (!SEREAL_ONLY) {
79
83
    $json_xs  = encode_json($data{json_xs}) if !$medium_data or $nobless;
80
84
    $dd1      = Data::Dumper->new([$data{dd1}])->Indent(0)->Dump();
102
106
        ["Storable", bytes::length($storable)],
103
107
        ["Sereal::Encoder",  bytes::length($sereal)],
104
108
        ["Sereal::Encoder, Snappy",  bytes::length($sereal_snappy)],
 
109
        ["Sereal::Encoder, Zlib (fast)",  bytes::length($sereal_zlib_fast)],
 
110
        ["Sereal::Encoder, Zlib (small)",  bytes::length($sereal_zlib_small)],
105
111
    );
106
112
    for my $tuple (@size_datasets) {
107
113
        my ($name, $size) = @$tuple;
130
136
            sereal_func => '$::x = encode_sereal($::data{sereal_func}, \%::opt);',
131
137
            sereal => '$::x = $::enc->encode($::data{sereal});',
132
138
            sereal_snappy => '$::x = $::enc_snappy->encode($::data{sereal_snappy});',
 
139
            sereal_zlib_fast => '$::x = $::enc_zlib_fast->encode($::data{sereal_zlib_fast});',
 
140
            sereal_zlib_small => '$::x = $::enc_zlib_small->encode($::data{sereal_zlib_small});',
133
141
        }
134
142
    );
135
143
}
152
160
            sereal_func => '$::x = decode_sereal($::sereal, \%::opt);',
153
161
            sereal => '$::x = $::dec->decode($::sereal);',
154
162
            sereal_snappy => '$::x = $::dec->decode($::sereal_snappy);',
 
163
            sereal_zlib_fast => '$::x = $::dec->decode($::sereal_zlib_fast);',
 
164
            sereal_zlib_small => '$::x = $::dec->decode($::sereal_zlib_small);',
155
165
        }
156
166
    );
157
167
}