… | |
… | |
86 | package JSON::XS; |
86 | package JSON::XS; |
87 | |
87 | |
88 | use strict; |
88 | use strict; |
89 | |
89 | |
90 | BEGIN { |
90 | BEGIN { |
91 | our $VERSION = '1.22'; |
91 | our $VERSION = '1.23'; |
92 | our @ISA = qw(Exporter); |
92 | our @ISA = qw(Exporter); |
93 | |
93 | |
94 | our @EXPORT = qw(to_json from_json objToJson jsonToObj); |
94 | our @EXPORT = qw(to_json from_json objToJson jsonToObj); |
95 | require Exporter; |
95 | require Exporter; |
96 | |
96 | |
… | |
… | |
616 | |
616 | |
617 | First comes a comparison between various modules using a very short |
617 | First comes a comparison between various modules using a very short |
618 | single-line JSON string: |
618 | single-line JSON string: |
619 | |
619 | |
620 | {"method": "handleMessage", "params": ["user1", "we were just talking"], \ |
620 | {"method": "handleMessage", "params": ["user1", "we were just talking"], \ |
621 | "id": null, [1,11,234,-5,1e5,1e7, true, false]} |
621 | "id": null, "array":[1,11,234,-5,1e5,1e7, true, false]} |
622 | |
622 | |
623 | It shows the number of encodes/decodes per second (JSON::XS uses the |
623 | It shows the number of encodes/decodes per second (JSON::XS uses the |
624 | functional interface, while JSON::XS/2 uses the OO interface with |
624 | functional interface, while JSON::XS/2 uses the OO interface with |
625 | pretty-printing and hashkey sorting enabled). Higher is better: |
625 | pretty-printing and hashkey sorting enabled). Higher is better: |
626 | |
626 | |
627 | -----------+------------+------------+ |
|
|
628 | module | encode | decode | |
627 | module | encode | decode | |
629 | -----------|------------|------------| |
628 | -----------|------------|------------| |
630 | JSON | 10597.029 | 5740.903 | |
629 | JSON | 7645.468 | 4208.613 | |
631 | JSON::DWIW | 78251.940 | 98457.840 | |
630 | JSON::DWIW | 68534.379 | 79437.576 | |
632 | JSON::PC | 70611.178 | 92794.336 | |
631 | JSON::PC | 65948.176 | 78251.940 | |
633 | JSON::Syck | 28767.517 | 38199.490 | |
632 | JSON::Syck | 23379.621 | 28416.694 | |
634 | JSON::XS | 419430.400 | 265462.278 | |
|
|
635 | JSON::XS/2 | 279620.267 | 265462.278 | |
|
|
636 | JSON::XS/3 | 388361.481 | 265462.278 | |
633 | JSON::XS | 388361.481 | 199728.762 | |
637 | Storable | 16294.887 | 16844.594 | |
634 | JSON::XS/2 | 218453.333 | 192399.266 | |
|
|
635 | JSON::XS/3 | 338250.323 | 192399.266 | |
|
|
636 | Storable | 15732.573 | 28571.553 | |
638 | -----------+------------+------------+ |
637 | -----------+------------+------------+ |
639 | |
638 | |
640 | That is, JSON::XS is about five times faster than JSON::DWIW on encoding, |
639 | That is, JSON::XS is about five times faster than JSON::DWIW on encoding, |
641 | about three times faster on decoding, and about fourty times faster |
640 | about three times faster on decoding, and over fourty times faster |
642 | than JSON, even with pretty-printing and key sorting. It also compares |
641 | than JSON, even with pretty-printing and key sorting. It also compares |
643 | favourably to Storable for small amounts of data. |
642 | favourably to Storable for small amounts of data. |
644 | |
643 | |
645 | Using a longer test string (roughly 18KB, generated from Yahoo! Locals |
644 | Using a longer test string (roughly 18KB, generated from Yahoo! Locals |
646 | search API (http://nanoref.com/yahooapis/mgPdGg): |
645 | search API (http://nanoref.com/yahooapis/mgPdGg): |