This is a playground to test JavaScript. It runs a completely standard copy of Node.js on a virtual server created just for you. Every one of npm’s 300,000+ packages are pre-installed, so try it out:
benchmarking my xml to json lib against other npm packages
var Benchmark = require('benchmark');
var {convertXML} = require("simple-xml-to-json")
var parseString = require('xml2js').parseString;
var suite = new Benchmark.Suite;
// some random XML to parse
var xmlToParse = `
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<n4IUJ2>
<DzFbTv>
<Z6ewIJR-SB3C alive="ants">Wt/X'&K#@k</Z6ewIJR-SB3C>
<JDhsG8yNFwleP hospital="people">
<la6Jwt>d^F|LA@u#+d(</la6Jwt>
<i45PLrnNM6vXeW doing="band"/>
<xPqIGtt>-1909725308.5405374</xPqIGtt>
<cV2z>1394190533.3263087</cV2z>
</JDhsG8yNFwleP>
<Hm4>
<c4kRe2 saw="own">C%:{y]VWx}}**4f</c4kRe2>
<C4B>-1307394759</C4B>
<ZcVyrAF7 had="term">-570786813.6594491</ZcVyrAF7>
<vN3hpFICyLA>-314209804</vN3hpFICyLA>
</Hm4>
<d7Axle bee="dawn">Jb##j</d7Axle>
</DzFbTv>
<nh6lzjh_>-598128031.2294636</nh6lzjh_>
<iqeBOQ1o1Oaq>Q1tHI>cV]z</iqeBOQ1o1Oaq>
<c4pnH tongue="being">L5=5,</c4pnH>
</n4IUJ2>
<vnz48uR1aCJ yourself="bridge">@WcQCxyD} 9</vnz48uR1aCJ>
<dUQMFHn45w past="victory">Bg?]eDii(\</dUQMFHn45w>
<Ab-Npen leg="curious">xOGFo19Eum</Ab-Npen>
</root>
`
// the tests
suite
.add('simple-xml-to-json', function() {
convertXML(xmlToParse)
})
.add('xml2js', function() {
parseString(xmlToParse, function (err, result) {
// console.dir(result);
});
})
.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').map('name'));
})
// run async
.run({ 'async': true });