Replace all instances of ; in the rowparser loop with , ( ~15% speedup )
[dbsrgits/DBIx-Class.git] / examples / Benchmarks / semicolon_vs_comma_rowparser / sloppy_bench.pl
CommitLineData
05a5ca4b 1use warnings;
2use strict;
3
4use Benchmark qw( cmpthese :hireswallclock);
5use Sereal;
6use Devel::Dwarn;
7
8my ($semicol, $comma) = map {
9 my $src = do { local (@ARGV, $/) = $_; <> };
10 eval "sub { use strict; use warnings; use warnings FATAL => 'uninitialized'; $src }" or die $@;
11} qw( semicol.src comma.src );
12
13my $enc = Sereal::Encoder->new;
14my $dec = Sereal::Decoder->new;
15
16for my $iters ( 100, 10_000, 100_000 ) {
17 my $dataset = [];
18 push @$dataset, [ (scalar @$dataset) x 11 ]
19 while @$dataset < $iters;
20
21 my $ice = $enc->encode($dataset);
22
23 print "\nTiming $iters 'rows'...\n";
24 cmpthese( -10, {
25 semicol => sub { $semicol->($dec->decode($ice)) },
26 comma => sub { $comma->($dec->decode($ice)) },
27 })
28}