Speeding up JSON parsing in Perl

I use the JSON package in a perl script that parses a long list of relatively short JSON strings, and I have profiled the process using Devel :: NYTProf. It seems that most of the time, the JSON string function is executed during parsing.

Are there any accelerations that I could use other than using the JSON package and try to speed it up by parsing it myself?

EDIT: The JSON package was installed on the system using cpanm . If there are any accelerations to optimize the installation process, they are also welcome.

+8
performance json perl
source share
2 answers

Try installing JSON :: XS . Then "use JSON" automatically uses the XS version. This module was written in C and it has very good performance.

+12
source share

Another interesting workaround:

If you need to parse JSON so that you can output smaller chunks from a large JSON object and the specified JSON object comes through webapp - just parse and compare the JSON with the smaller JavaScript fragment before sending it to Perl.

JS has surprisingly fast and efficient parsers from strings to JSON (the Douglas Crockford parser , not eval to be clear), even if you start with the string and not the JSON data structure itself.

0
source share

All Articles