Skip Menu |

This queue is for tickets about the Benchmark-Serialize CPAN distribution.

Report information
The Basics
Id: 64757
Status: new
Priority: 0/
Queue: Benchmark-Serialize

People
Owner: Nobody in particular
Requestors: neil [...] neely.cx
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Add benchmark for Data::Serializer::Raw
Thank you for the review of Data::Serializer, in it you raised a couple great points. #1 It would have been nice if it behaved in "raw" mode by default and #2 it has quite a lot of overhead by default As to #1 - I agree strongly, but my time machine broke, so in lieu of that I've opted to add "Data::Serializer::Raw" as a module that comes with Data::Serializer that you can construct from directly that is lean and only provides a unified interface to the underlying serializers. This helps considerably with #2 as well. It isn't as fast as not wrapping the code in the first place, but it isn't nearly so punitive. I've attached "Raw.pm" intended to be added into Benchmark::Serialize as - Benchmark::Serialize::Library::Data::Serializer::Raw.pm Data::Serializer::Raw is introduced in Data::Serializer version 0.54 which I just uploaded a few minutes ago (1/13/2011) so will be available soon.
Subject: Raw.pm
package Benchmark::Serialize::Library::Data::Serializer::Raw; use strict; use warnings; use Benchmark::Serialize::Library; use Scalar::Util qw(blessed); =head1 NAME Benchmark::Serialize::Library::Data::Serializer::Raw - Data::Serializer::Raw benchmarks =head1 SYNOPSIS # Register tests on use time use Benchmark::Serializer::Library::Data::Serializer::Raw qw(JSON); # Register tests on run time Benchmark::Serializer::Library::Data::Serializer::Raw->register('JSON'); =head1 DESCRIPTION This modules adds a set of benchmarks to L<Benchmark::Serialize> for different uses of the L<Data::Serializer::Raw> modules. Both native Data::Serializer bridges and the wrapping of existing benchmarks in a generic Data::Serializer bridge is supported. If the argument to import/register starts with a '+' it is interpreted as a existing benchmark to be wrapped in the generic wrapper. Other wise the argument is interpreted as a normal Data::Serializer::Raw bridge. Note that the generic bridge is a bit slower than a hand crafted bridge would be. =head1 Benchmark tags For each added serializer a new Benchmark tag is created called C<:DSR-<nameE<gt>>, i.e C<:DSR-JSON> if used as in the synopsis =cut sub import { my $pkg = shift; my @imports = map { /^\+(.*)/ ? Benchmark::Serialize::Library->load($1) : $_ } @_; for (@imports) { my $module = blessed $_ ? "Benchmark::Serialize" : $_; my $name = blessed $_ ? $_->name : $_; my $basename = blessed $_ ? $_->name . ",ds" : "Data::Serializer::Raw::$module"; my %extra = blessed $_ ? %$_ : (); my %options = ( deflate => \&std_deflate, inflate => \&std_inflate, packages => [ 'Data::Serializer::Raw' ], "DSR-$name" => 1, ); Benchmark::Serialize::Library->register( $basename => { %options, args => sub { Data::Serializer::Raw->new( serializer => $module, options => \%extra ); }, } ); } } sub register { my $pkg = shift; $pkg->import( @_ ); } sub std_deflate { $_[1]->serialize( $_[0] ); } sub std_inflate { $_[1]->deserialize( $_[0] ); } =head1 SEE ALSO L<Data::Serializer::Raw> =head1 AUTHOR Neil Neely, C<< <neil@neely.cx> >> Based on Benchmark::Serialize::Data::Serializer Peter Makholm, C<< <peter at makholm.net> >> =head1 COPYRIGHT & LICENSE Copyright 2011 Neil Neely This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. =cut 1;