… | |
… | |
46 | In short, CBOR is a faster and very compact binary alternative to JSON, |
46 | In short, CBOR is a faster and very compact binary alternative to JSON, |
47 | with the added ability of supporting serialisation of Perl objects. (JSON |
47 | with the added ability of supporting serialisation of Perl objects. (JSON |
48 | often compresses better than CBOR though, so if you plan to compress the |
48 | often compresses better than CBOR though, so if you plan to compress the |
49 | data later you might want to compare both formats first). |
49 | data later you might want to compare both formats first). |
50 | |
50 | |
51 | To give you a general idea, with texts in the megabyte range, C<CBOR::XS> |
51 | To give you a general idea about speed, with texts in the megabyte range, |
52 | usually encodes roughly twice as fast as L<Storable> or L<JSON::XS> and |
52 | C<CBOR::XS> usually encodes roughly twice as fast as L<Storable> or |
53 | decodes about 15%-30% faster than those. The shorter the data, the worse |
53 | L<JSON::XS> and decodes about 15%-30% faster than those. The shorter the |
54 | L<Storable> performs in comparison. |
54 | data, the worse L<Storable> performs in comparison. |
|
|
55 | |
|
|
56 | As for compactness, C<CBOR::XS> encoded data structures are usually about |
|
|
57 | 20% smaller than the same data encoded as (compact) JSON or L<Storable>. |
55 | |
58 | |
56 | The primary goal of this module is to be I<correct> and the secondary goal |
59 | The primary goal of this module is to be I<correct> and the secondary goal |
57 | is to be I<fast>. To reach the latter goal it was written in C. |
60 | is to be I<fast>. To reach the latter goal it was written in C. |
58 | |
61 | |
59 | See MAPPING, below, on how CBOR::XS maps perl values to CBOR values and |
62 | See MAPPING, below, on how CBOR::XS maps perl values to CBOR values and |
… | |
… | |
63 | |
66 | |
64 | package CBOR::XS; |
67 | package CBOR::XS; |
65 | |
68 | |
66 | use common::sense; |
69 | use common::sense; |
67 | |
70 | |
68 | our $VERSION = 0.06; |
71 | our $VERSION = 0.07; |
69 | our @ISA = qw(Exporter); |
72 | our @ISA = qw(Exporter); |
70 | |
73 | |
71 | our @EXPORT = qw(encode_cbor decode_cbor); |
74 | our @EXPORT = qw(encode_cbor decode_cbor); |
72 | |
75 | |
73 | use Exporter; |
76 | use Exporter; |