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.14 by root, Tue Oct 29 20:59:16 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, with texts in the megabyte range, C<CBOR::XS> 51To give you a general idea about speed, with texts in the megabyte range,
52usually encodes roughly twice as fast as L<Storable> or L<JSON::XS> and 52C<CBOR::XS> usually encodes roughly twice as fast as L<Storable> or
53decodes about 15%-30% faster than those. The shorter the data, the worse 53L<JSON::XS> and decodes about 15%-30% faster than those. The shorter the
54L<Storable> performs in comparison. 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>.
55 58
56The 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
57is 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.
58 61
59See 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
63 66
64package CBOR::XS; 67package CBOR::XS;
65 68
66use common::sense; 69use common::sense;
67 70
68our $VERSION = 0.06; 71our $VERSION = 0.08;
69our @ISA = qw(Exporter); 72our @ISA = qw(Exporter);
70 73
71our @EXPORT = qw(encode_cbor decode_cbor); 74our @EXPORT = qw(encode_cbor decode_cbor);
72 75
73use Exporter; 76use Exporter;
452=head1 MAGIC HEADER 455=head1 MAGIC HEADER
453 456
454There is no way to distinguish CBOR from other formats 457There is no way to distinguish CBOR from other formats
455programmatically. To make it easier to distinguish CBOR from other 458programmatically. To make it easier to distinguish CBOR from other
456formats, the CBOR specification has a special "magic string" that can be 459formats, the CBOR specification has a special "magic string" that can be
457prepended to any CBOR string without changing it's meaning. 460prepended to any CBOR string without changing its meaning.
458 461
459This 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
460prepend 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
461if 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
462required. 465required.
463 466
464 467
465=head1 THE CBOR::XS::Tagged CLASS 468=head1 THE CBOR::XS::Tagged CLASS

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines