… | |
… | |
1201 | single-line JSON string (also available at |
1201 | single-line JSON string (also available at |
1202 | <http://dist.schmorp.de/misc/json/short.json>). |
1202 | <http://dist.schmorp.de/misc/json/short.json>). |
1203 | |
1203 | |
1204 | {"method": "handleMessage", "params": ["user1", |
1204 | {"method": "handleMessage", "params": ["user1", |
1205 | "we were just talking"], "id": null, "array":[1,11,234,-5,1e5,1e7, |
1205 | "we were just talking"], "id": null, "array":[1,11,234,-5,1e5,1e7, |
1206 | true, false]} |
1206 | 1, 0]} |
1207 | |
1207 | |
1208 | It shows the number of encodes/decodes per second (JSON::XS uses the |
1208 | It shows the number of encodes/decodes per second (JSON::XS uses the |
1209 | functional interface, while JSON::XS/2 uses the OO interface with |
1209 | functional interface, while JSON::XS/2 uses the OO interface with |
1210 | pretty-printing and hashkey sorting enabled, JSON::XS/3 enables shrink). |
1210 | pretty-printing and hashkey sorting enabled, JSON::XS/3 enables shrink. |
1211 | Higher is better: |
1211 | JSON::DWIW/DS uses the deserialise function, while JSON::DWIW::FJ uses |
|
|
1212 | the from_json method). Higher is better: |
1212 | |
1213 | |
1213 | module | encode | decode | |
1214 | module | encode | decode | |
1214 | -----------|------------|------------| |
1215 | --------------|------------|------------| |
1215 | JSON 1.x | 4990.842 | 4088.813 | |
1216 | JSON::DWIW/DS | 86302.551 | 102300.098 | |
1216 | JSON::DWIW | 51653.990 | 71575.154 | |
1217 | JSON::DWIW/FJ | 86302.551 | 75983.768 | |
1217 | JSON::PC | 65948.176 | 74631.744 | |
1218 | JSON::PP | 15827.562 | 6638.658 | |
1218 | JSON::PP | 8931.652 | 3817.168 | |
1219 | JSON::Syck | 63358.066 | 47662.545 | |
1219 | JSON::Syck | 24877.248 | 27776.848 | |
1220 | JSON::XS | 511500.488 | 511500.488 | |
1220 | JSON::XS | 388361.481 | 227951.304 | |
1221 | JSON::XS/2 | 291271.111 | 388361.481 | |
1221 | JSON::XS/2 | 227951.304 | 218453.333 | |
1222 | JSON::XS/3 | 361577.931 | 361577.931 | |
1222 | JSON::XS/3 | 338250.323 | 218453.333 | |
1223 | Storable | 66788.280 | 265462.278 | |
1223 | Storable | 16500.016 | 135300.129 | |
|
|
1224 | -----------+------------+------------+ |
1224 | --------------+------------+------------+ |
1225 | |
1225 | |
1226 | That is, JSON::XS is about five times faster than JSON::DWIW on |
1226 | That is, JSON::XS is almost six times faster than JSON::DWIW on |
1227 | encoding, about three times faster on decoding, and over forty times |
1227 | encoding, about five times faster on decoding, and over thirty to |
1228 | faster than JSON, even with pretty-printing and key sorting. It also |
1228 | seventy times faster than JSON's pure perl implementation. It also |
1229 | compares favourably to Storable for small amounts of data. |
1229 | compares favourably to Storable for small amounts of data. |
1230 | |
1230 | |
1231 | Using a longer test string (roughly 18KB, generated from Yahoo! Locals |
1231 | Using a longer test string (roughly 18KB, generated from Yahoo! Locals |
1232 | search API (<http://dist.schmorp.de/misc/json/long.json>). |
1232 | search API (<http://dist.schmorp.de/misc/json/long.json>). |
1233 | |
1233 | |
1234 | module | encode | decode | |
1234 | module | encode | decode | |
1235 | -----------|------------|------------| |
1235 | --------------|------------|------------| |
1236 | JSON 1.x | 55.260 | 34.971 | |
1236 | JSON::DWIW/DS | 1647.927 | 2673.916 | |
1237 | JSON::DWIW | 825.228 | 1082.513 | |
1237 | JSON::DWIW/FJ | 1630.249 | 2596.128 | |
1238 | JSON::PC | 3571.444 | 2394.829 | |
|
|
1239 | JSON::PP | 210.987 | 32.574 | |
1238 | JSON::PP | 400.640 | 62.311 | |
1240 | JSON::Syck | 552.551 | 787.544 | |
1239 | JSON::Syck | 1481.040 | 1524.869 | |
1241 | JSON::XS | 5780.463 | 4854.519 | |
1240 | JSON::XS | 20661.596 | 9541.183 | |
1242 | JSON::XS/2 | 3869.998 | 4798.975 | |
1241 | JSON::XS/2 | 10683.403 | 9416.938 | |
1243 | JSON::XS/3 | 5862.880 | 4798.975 | |
1242 | JSON::XS/3 | 20661.596 | 9400.054 | |
1244 | Storable | 4445.002 | 5235.027 | |
1243 | Storable | 19765.806 | 10000.725 | |
1245 | -----------+------------+------------+ |
1244 | --------------+------------+------------+ |
1246 | |
1245 | |
1247 | Again, JSON::XS leads by far (except for Storable which non-surprisingly |
1246 | Again, JSON::XS leads by far (except for Storable which non-surprisingly |
1248 | decodes faster). |
1247 | decodes a bit faster). |
1249 | |
1248 | |
1250 | On large strings containing lots of high Unicode characters, some |
1249 | On large strings containing lots of high Unicode characters, some |
1251 | modules (such as JSON::PC) seem to decode faster than JSON::XS, but the |
1250 | modules (such as JSON::PC) seem to decode faster than JSON::XS, but the |
1252 | result will be broken due to missing (or wrong) Unicode handling. Others |
1251 | result will be broken due to missing (or wrong) Unicode handling. Others |
1253 | refuse to decode or encode properly, so it was impossible to prepare a |
1252 | refuse to decode or encode properly, so it was impossible to prepare a |