Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^6: a *working* JSON module (Perl's Debugger), related issues

by stevieb (Canon)
on Oct 30, 2021 at 20:51 UTC ( [id://11138258]=note: print w/replies, xml ) Need Help??


in reply to Re^5: a *working* JSON module (Perl's Debugger), related issues
in thread Can someone please write a *working* JSON module

Q3) Does Data::Roundtrip cover the same ground that JSON::XS did? I can't disambiguate what XS means.

Data::Roundtrip requires the JSON distribution. When used, the JSON module will load JSON::XS if it is available to your interpreter, and the pure perl JSON::PP if not. JSON::PP has been in core since ~5.14, so this functionality is very handy instead of just having your script fall over if JSON::XS isn't installed.

XS simply means that there are components to the software that are compiled, therefore in most cases making much of its functionality much, much faster.

One of my distributions, Bit::Manip is an XS based module, but I also have a pure perl version (Bit::Manip::PP) for those who can't or don't want to compile software. Here's a benchmark script between the two, and the results. The C/XS version is ~394% faster than the pure perl version:

use warnings; use strict; # performs a benchmark between this XS # version and the PP version use Benchmark qw(timethese cmpthese); use Bit::Manip; use Bit::Manip::PP; my $do = $ARGV[0]; timethese(1000000, { 'c' => 'c', 'p' => 'p', } ); cmpthese(1000000, { 'c' => 'c', 'p' => 'p', } ); sub c { Bit::Manip::bit_set(65535, 0, 8, 0xFF); } sub p { Bit::Manip::PP::bit_set(65535, 0, 8, 0xFF); } __END__ Benchmark: timing 1000000 iterations of c, p... c: 3 wallclock secs ( 3.35 usr + 0.00 sys = 3.35 CPU) @ 29 +8507.46/s (n=1000000) p: 17 wallclock secs (16.58 usr + 0.00 sys = 16.58 CPU) @ 60 +313.63/s (n=1000000) Rate p c p 60606/s -- -80% c 299401/s 394% --

Replies are listed 'Best First'.
Naming XS modules (was: Re^7: a *working* JSON module (Perl's Debugger), related issues)
by Bod (Parson) on Oct 30, 2021 at 21:40 UTC
    One of my distributions, Bit::Manip is an XS based module, but I also have a pure perl version (Bit::Manip::PP)

    I'm intrigued why you called one Bit::Manip::PP but didn't name the other Bit::Manip::XS. Intrigued because naming of modules seems a bit of a dark art to me despite all the advice on the matter.

      I'm intrigued why you called one Bit::Manip::PP but didn't name the other Bit::Manip::XS

      Because I had written the entirety of Bit::Manip in C and XS, then front-ended it in Perl and released it. It was only after a while later I decided to do a rewrite in pure Perl and release that separately. No reason other than it had already been released as Bit::Manip.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11138258]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-18 03:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found