Data-StreamDeserializer
view release on metacpan or search on metacpan
lib/Data/StreamDeserializer.pm view on Meta::CPAN
=head2 is_error
Returns B<TRUE> if an error was detected.
=head2 error
Returns error string.
=head2 tail
Returns unparsed data.
=head2 result
Returns result of parsing. By default the function returns only
the first parsed object.
You can call the function with argument B<'all'>
to get all parsed objects. In this case the function will receive
B<ARRAYREF>.
=head2 is_done
Returns B<TRUE> if all input data were processed or an error was found.
If You didn't call L<part> without arguments, and didn't call L<next>
or L<next_object> with B<undef> the function could return B<TRUE> only
if an error occured.
=head1 PRIVATE METHODS
=head2 _push_error
Pushes error into deserializer's error stack.
=head1 SEE ALSO
L<DATA::StreamSerializer>
=head1 BENCHMARKS
This module is almost fully written using XS/C language. So it works
a bit faster or slowly than L<CORE::eval>.
You can try a few scripts in B<benchmark/> directory. There are a few
test arrays in this directory.
Here are a few test results of my system.
=head2 Array which contains 100 hashes:
It works faster than B<eval>:
$ perl benchmark/ds_vs_eval.pl -n 1000 -b 512 benchmark/tests/01_100x10
38296 bytes were read
First deserializing by eval... done
First deserializing by Data::DeSerializer... done
Check if deserialized objects are same... done
Starting 1000 iterations for eval... done (3.755 seconds)
Starting 1000 iterations for Data::StreamDeserializer... done (3.059 seconds)
Eval statistic:
1000 iterations were done
maximum deserialization time: 0.0041 seconds
minimum deserialization time: 0.0035 seconds
average deserialization time: 0.0036 seconds
StreamDeserializer statistic:
1000 iterations were done
75000 SUBiterations were done
512 bytes in one block in one iteration
maximum deserialization time: 0.0045 seconds
minimum deserialization time: 0.0028 seconds
average deserialization time: 0.0029 seconds
average subiteration time: 0.00004 seconds
=head2 Array which contains 1000 hashes:
It works slowly than B<eval>:
$ perl benchmark/ds_vs_eval.pl -n 1000 -b 512 benchmark/tests/02_1000x10
355623 bytes were read
First deserializing by eval... done
First deserializing by Data::DeSerializer... done
Check if deserialized objects are same... done
Starting 1000 iterations for eval... done (43.920 seconds)
Starting 1000 iterations for Data::StreamDeserializer... done (71.668 seconds)
Eval statistic:
1000 iterations were done
maximum deserialization time: 0.0490 seconds
minimum deserialization time: 0.0416 seconds
average deserialization time: 0.0426 seconds
StreamDeserializer statistic:
1000 iterations were done
689000 SUBiterations were done
512 bytes in one block in one iteration
maximum deserialization time: 0.0773 seconds
minimum deserialization time: 0.0656 seconds
average deserialization time: 0.0690 seconds
average subiteration time: 0.00010 seconds
You can see, that one block is parsed in a very short time period. So You
can increase L<block_size> value to reduce total parsing time.
If B<block_size> is equal string size the module works two times
faster than eval:
$ perl benchmark/ds_vs_eval.pl -n 1000 -b 355623 benchmark/tests/02_1000x10
355623 bytes were read
First deserializing by eval... done
First deserializing by Data::DeSerializer... done
Check if deserialized objects are same... done
Starting 1000 iterations for eval... done (44.456 seconds)
Starting 1000 iterations for Data::StreamDeserializer... done (19.702 seconds)
Eval statistic:
1000 iterations were done
maximum deserialization time: 0.0474 seconds
minimum deserialization time: 0.0423 seconds
average deserialization time: 0.0431 seconds
StreamDeserializer statistic:
1000 iterations were done
1000 SUBiterations were done
355623 bytes in one block in one iteration
maximum deserialization time: 0.0179 seconds
minimum deserialization time: 0.0168 seconds
average deserialization time: 0.0171 seconds
average subiteration time: 0.01705 seconds
=head1 AUTHOR
Dmitry E. Oboukhov, E<lt>unera@debian.orgE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2011 by Dmitry E. Oboukhov
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.10.1 or,
at your option, any later version of Perl 5 you may have available.
=head1 VCS
The project is placed in my git repo. See here:
L<http://git.uvw.ru/?p=data-stream-deserializer;a=summary>
=cut
( run in 0.519 second using v1.01-cache-2.11-cpan-71847e10f99 )