… | |
… | |
457 | tables. They have been generated with the help of the "eg/bench" program |
457 | tables. They have been generated with the help of the "eg/bench" program |
458 | in the JSON::XS distribution, to make it easy to compare on your own |
458 | in the JSON::XS distribution, to make it easy to compare on your own |
459 | system. |
459 | system. |
460 | |
460 | |
461 | First comes a comparison between various modules using a very short JSON |
461 | First comes a comparison between various modules using a very short JSON |
462 | string (83 bytes), showing the number of encodes/decodes per second |
462 | string: |
463 | (JSON::XS is the functional interface, while JSON::XS/2 is the OO |
463 | |
|
|
464 | {"method": "handleMessage", "params": ["user1", "we were just talking"], "id": null} |
|
|
465 | |
|
|
466 | It shows the number of encodes/decodes per second (JSON::XS uses the |
|
|
467 | functional interface, while JSON::XS/2 uses the OO interface with |
464 | interface with pretty-printing and hashkey sorting enabled). Higher is |
468 | pretty-printing and hashkey sorting enabled). Higher is better: |
465 | better: |
|
|
466 | |
469 | |
467 | module | encode | decode | |
470 | module | encode | decode | |
468 | -----------|------------|------------| |
471 | -----------|------------|------------| |
469 | JSON | 14006 | 6820 | |
472 | JSON | 11488.516 | 7823.035 | |
470 | JSON::DWIW | 200937 | 120386 | |
473 | JSON::DWIW | 94708.054 | 129094.260 | |
471 | JSON::PC | 85065 | 129366 | |
474 | JSON::PC | 63884.157 | 128528.212 | |
472 | JSON::Syck | 59898 | 44232 | |
475 | JSON::Syck | 34898.677 | 42096.911 | |
473 | JSON::XS | 1171478 | 342435 | |
476 | JSON::XS | 654027.064 | 396423.669 | |
474 | JSON::XS/2 | 730760 | 328714 | |
477 | JSON::XS/2 | 371564.190 | 371725.613 | |
475 | -----------+------------+------------+ |
478 | -----------+------------+------------+ |
476 | |
479 | |
477 | That is, JSON::XS is 6 times faster than than JSON::DWIW and about 80 |
480 | That is, JSON::XS is more than six times faster than JSON::DWIW on |
|
|
481 | encoding, more than three times faster on decoding, and about thirty |
478 | times faster than JSON, even with pretty-printing and key sorting. |
482 | times faster than JSON, even with pretty-printing and key sorting. |
479 | |
483 | |
480 | Using a longer test string (roughly 18KB, generated from Yahoo! Locals |
484 | Using a longer test string (roughly 18KB, generated from Yahoo! Locals |
481 | search API (http://nanoref.com/yahooapis/mgPdGg): |
485 | search API (http://nanoref.com/yahooapis/mgPdGg): |
482 | |
486 | |
483 | module | encode | decode | |
487 | module | encode | decode | |
484 | -----------|------------|------------| |
488 | -----------|------------|------------| |
485 | JSON | 673 | 38 | |
489 | JSON | 273.023 | 44.674 | |
486 | JSON::DWIW | 5271 | 770 | |
490 | JSON::DWIW | 1089.383 | 1145.704 | |
487 | JSON::PC | 9901 | 2491 | |
491 | JSON::PC | 3097.419 | 2393.921 | |
488 | JSON::Syck | 2360 | 786 | |
492 | JSON::Syck | 514.060 | 843.053 | |
489 | JSON::XS | 37398 | 3202 | |
493 | JSON::XS | 6479.668 | 3636.364 | |
490 | JSON::XS/2 | 13765 | 3153 | |
494 | JSON::XS/2 | 3774.221 | 3599.124 | |
491 | -----------+------------+------------+ |
495 | -----------+------------+------------+ |
492 | |
496 | |
493 | Again, JSON::XS leads by far in the encoding case, while still beating |
497 | Again, JSON::XS leads by far. |
494 | every other module in the decoding case. |
|
|
495 | |
498 | |
496 | On large strings containing lots of unicode characters, some modules |
499 | On large strings containing lots of high unicode characters, some |
497 | (such as JSON::PC) decode faster than JSON::XS, but the result will be |
500 | modules (such as JSON::PC) seem to decode faster than JSON::XS, but the |
498 | broken due to missing unicode handling. Others refuse to decode or |
501 | result will be broken due to missing (or wrong) unicode handling. Others |
499 | encode properly, so it was impossible to prepare a fair comparison table |
502 | refuse to decode or encode properly, so it was impossible to prepare a |
500 | for that case. |
503 | fair comparison table for that case. |
501 | |
504 | |
502 | RESOURCE LIMITS |
505 | RESOURCE LIMITS |
503 | JSON::XS does not impose any limits on the size of JSON texts or Perl |
506 | JSON::XS does not impose any limits on the size of JSON texts or Perl |
504 | values they represent - if your machine can handle it, JSON::XS will |
507 | values they represent - if your machine can handle it, JSON::XS will |
505 | encode or decode it. Future versions might optionally impose structure |
508 | encode or decode it. Future versions might optionally impose structure |