Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
eval makes JSON::XS even slower than JSON::PP

Erm . . . Citation needed.

#!/usr/bin/env perl use 5.032; use Benchmark qw( :all ); use JSON::PP (); use JSON::XS (); use Cpanel::JSON::XS (); my $good_data = q{{"a": 1, "b": 2, "c": 3}}; my $bad_data = q{{Invalid: JSON, IS: Invalid}}; my @lots_o_good = ($good_data) x 50; my @lots_o_bad = ($bad_data) x 50; cmpthese( 5_000, { pp_good_no_eval => sub { my $parsed; for my $line (@lots_o_good) { $parsed = JSON::PP::decode_json($line); } }, pp_good_eval => sub { my $parsed; for my $line (@lots_o_good) { $parsed = eval { JSON::PP::decode_json($line) }; } }, pp_bad => sub { my $parsed; for my $line (@lots_o_bad) { $parsed = eval { JSON::PP::decode_json($line) }; } }, xs_good => sub { my $parsed; for my $line (@lots_o_good) { $parsed = JSON::XS::decode_json($line); } }, xs_good_eval => sub { my $parsed; for my $line (@lots_o_good) { $parsed = eval { JSON::XS::decode_json($line) }; } }, xs_bad => sub { my $parsed; for my $line (@lots_o_bad) { $parsed = eval { JSON::XS::decode_json($line) }; } }, cpanel_good => sub { my $parsed; for my $line (@lots_o_good) { $parsed = Cpanel::JSON::XS::decode_json($line); } }, cpanel_good_eval => sub { my $parsed; for my $line (@lots_o_good) { $parsed = eval { Cpanel::JSON::XS::decode_json($line) +}; } }, cpanel_bad => sub { my $parsed; for my $line (@lots_o_bad) { $parsed = eval { Cpanel::JSON::XS::decode_json($line) +}; } }, } ); exit 0; __END__ Rate pp_bad pp_good_eval pp_good_no_eval xs_bad cp +anel_bad cpanel_good_eval xs_good_eval cpanel_good xs_good pp_bad 228/s -- -55% -56% -97% + -97% -99% -99% -99% -99% pp_good_eval 510/s 124% -- -1% -92% + -93% -98% -98% -99% -99% pp_good_no_eval 514/s 125% 1% -- -92% + -93% -98% -98% -99% -99% xs_bad 6757/s 2865% 1226% 1215% -- + -8% -80% -80% -82% -82% cpanel_bad 7353/s 3126% 1343% 1331% 9% + -- -78% -78% -81% -81% cpanel_good_eval 33333/s 14527% 6440% 6387% 393% + 353% -- -0% -13% -13% xs_good_eval 33333/s 14527% 6440% 6387% 393% + 353% 0% -- -13% -13% cpanel_good 38462/s 16777% 7446% 7385% 469% + 423% 15% 15% -- -0% xs_good 38462/s 16777% 7446% 7385% 469% + 423% 15% 15% 0% --

The cake is a lie.
The cake is a lie.
The cake is a lie.


In reply to Re: Can someone please write a *working* JSON module by Fletch
in thread Can someone please write a *working* JSON module by cnd

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-29 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found