ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/JSON-XS/README
(Generate patch)

Comparing JSON-XS/README (file contents):
Revision 1.4 by root, Fri Mar 23 18:33:50 2007 UTC vs.
Revision 1.5 by root, Sat Mar 24 01:15:22 2007 UTC

267 refers to the abstract Perl language itself. 267 refers to the abstract Perl language itself.
268 268
269 JSON -> PERL 269 JSON -> PERL
270 object 270 object
271 A JSON object becomes a reference to a hash in Perl. No ordering of 271 A JSON object becomes a reference to a hash in Perl. No ordering of
272 object keys is preserved. 272 object keys is preserved (JSON does not preserver object key
273 ordering itself).
273 274
274 array 275 array
275 A JSON array becomes a reference to an array in Perl. 276 A JSON array becomes a reference to an array in Perl.
276 277
277 string 278 string
303 304
304 hash references 305 hash references
305 Perl hash references become JSON objects. As there is no inherent 306 Perl hash references become JSON objects. As there is no inherent
306 ordering in hash keys, they will usually be encoded in a 307 ordering in hash keys, they will usually be encoded in a
307 pseudo-random order that can change between runs of the same program 308 pseudo-random order that can change between runs of the same program
308 but stays generally the same within the single run of a program. 309 but stays generally the same within a single run of a program.
309 JSON::XS can optionally sort the hash keys (determined by the 310 JSON::XS can optionally sort the hash keys (determined by the
310 *canonical* flag), so the same datastructure will serialise to the 311 *canonical* flag), so the same datastructure will serialise to the
311 same JSON text (given same settings and version of JSON::XS), but 312 same JSON text (given same settings and version of JSON::XS), but
312 this incurs a runtime overhead. 313 this incurs a runtime overhead.
313 314
440 It seems that JSON::XS is surprisingly fast, as shown in the following 441 It seems that JSON::XS is surprisingly fast, as shown in the following
441 tables. They have been generated with the help of the "eg/bench" program 442 tables. They have been generated with the help of the "eg/bench" program
442 in the JSON::XS distribution, to make it easy to compare on your own 443 in the JSON::XS distribution, to make it easy to compare on your own
443 system. 444 system.
444 445
445 First is a comparison between various modules using a very simple JSON 446 First comes a comparison between various modules using a very short JSON
446 string, showing the number of encodes/decodes per second (JSON::XS is 447 string (83 bytes), showing the number of encodes/decodes per second
447 the functional interface, while JSON::XS/2 is the OO interface with 448 (JSON::XS is the functional interface, while JSON::XS/2 is the OO
448 pretty-printing and hashkey sorting enabled). 449 interface with pretty-printing and hashkey sorting enabled). Higher is
450 better:
449 451
450 module | encode | decode | 452 module | encode | decode |
451 -----------|------------|------------| 453 -----------|------------|------------|
452 JSON | 14006 | 6820 | 454 JSON | 14006 | 6820 |
453 JSON::DWIW | 200937 | 120386 | 455 JSON::DWIW | 200937 | 120386 |
458 -----------+------------+------------+ 460 -----------+------------+------------+
459 461
460 That is, JSON::XS is 6 times faster than than JSON::DWIW and about 80 462 That is, JSON::XS is 6 times faster than than JSON::DWIW and about 80
461 times faster than JSON, even with pretty-printing and key sorting. 463 times faster than JSON, even with pretty-printing and key sorting.
462 464
463 Using a longer test string (roughly 8KB, generated from Yahoo! Locals 465 Using a longer test string (roughly 18KB, generated from Yahoo! Locals
464 search API (http://nanoref.com/yahooapis/mgPdGg): 466 search API (http://nanoref.com/yahooapis/mgPdGg):
465 467
466 module | encode | decode | 468 module | encode | decode |
467 -----------|------------|------------| 469 -----------|------------|------------|
468 JSON | 673 | 38 | 470 JSON | 673 | 38 |
474 -----------+------------+------------+ 476 -----------+------------+------------+
475 477
476 Again, JSON::XS leads by far in the encoding case, while still beating 478 Again, JSON::XS leads by far in the encoding case, while still beating
477 every other module in the decoding case. 479 every other module in the decoding case.
478 480
481 On large strings containing lots of unicode characters, some modules
482 (such as JSON::PC) decode faster than JSON::XS, but the result will be
483 broken due to missing unicode handling. Others refuse to decode or
484 encode properly, so it was impossible to prepare a fair comparison table
485 for that case.
486
479RESOURCE LIMITS 487RESOURCE LIMITS
480 JSON::XS does not impose any limits on the size of JSON texts or Perl 488 JSON::XS does not impose any limits on the size of JSON texts or Perl
481 values they represent - if your machine can handle it, JSON::XS will 489 values they represent - if your machine can handle it, JSON::XS will
482 encode or decode it. Future versions might optionally impose structure 490 encode or decode it. Future versions might optionally impose structure
483 depth and memory use resource limits. 491 depth and memory use resource limits.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines