ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CBOR-XS/XS.pm
(Generate patch)

Comparing CBOR-XS/XS.pm (file contents):
Revision 1.13 by root, Tue Oct 29 15:56:31 2013 UTC vs.
Revision 1.18 by root, Sun Nov 17 05:26:14 2013 UTC

46In short, CBOR is a faster and very compact binary alternative to JSON, 46In short, CBOR is a faster and very compact binary alternative to JSON,
47with the added ability of supporting serialisation of Perl objects. (JSON 47with the added ability of supporting serialisation of Perl objects. (JSON
48often compresses better than CBOR though, so if you plan to compress the 48often compresses better than CBOR though, so if you plan to compress the
49data later you might want to compare both formats first). 49data later you might want to compare both formats first).
50 50
51To give you a general idea about speed, with texts in the megabyte range,
52C<CBOR::XS> usually encodes roughly twice as fast as L<Storable> or
53L<JSON::XS> and decodes about 15%-30% faster than those. The shorter the
54data, the worse L<Storable> performs in comparison.
55
56As for compactness, C<CBOR::XS> encoded data structures are usually about
5720% smaller than the same data encoded as (compact) JSON or L<Storable>.
58
51The primary goal of this module is to be I<correct> and the secondary goal 59The primary goal of this module is to be I<correct> and the secondary goal
52is to be I<fast>. To reach the latter goal it was written in C. 60is to be I<fast>. To reach the latter goal it was written in C.
53 61
54See MAPPING, below, on how CBOR::XS maps perl values to CBOR values and 62See MAPPING, below, on how CBOR::XS maps perl values to CBOR values and
55vice versa. 63vice versa.
58 66
59package CBOR::XS; 67package CBOR::XS;
60 68
61use common::sense; 69use common::sense;
62 70
63our $VERSION = 0.06; 71our $VERSION = 0.08;
64our @ISA = qw(Exporter); 72our @ISA = qw(Exporter);
65 73
66our @EXPORT = qw(encode_cbor decode_cbor); 74our @EXPORT = qw(encode_cbor decode_cbor);
67 75
68use Exporter; 76use Exporter;
447=head1 MAGIC HEADER 455=head1 MAGIC HEADER
448 456
449There is no way to distinguish CBOR from other formats 457There is no way to distinguish CBOR from other formats
450programmatically. To make it easier to distinguish CBOR from other 458programmatically. To make it easier to distinguish CBOR from other
451formats, the CBOR specification has a special "magic string" that can be 459formats, the CBOR specification has a special "magic string" that can be
452prepended to any CBOR string without changing it's meaning. 460prepended to any CBOR string without changing its meaning.
453 461
454This string is available as C<$CBOR::XS::MAGIC>. This module does not 462This string is available as C<$CBOR::XS::MAGIC>. This module does not
455prepend this string tot he CBOR data it generates, but it will ignroe it 463prepend this string to the CBOR data it generates, but it will ignore it
456if present, so users can prepend this string as a "file type" indicator as 464if present, so users can prepend this string as a "file type" indicator as
457required. 465required.
458 466
459 467
460=head1 THE CBOR::XS::Tagged CLASS 468=head1 THE CBOR::XS::Tagged CLASS

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines