Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions benchmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# fast-xml-parser benchmarks

Part of [fast-xml-parser](../README.md)

## Building

```shell
$ npm i
```

## Testing

### All Benchmarks

```shell
$ npm t
```

### Parser Benchmars

```shell
$ npm run parser
```

### Builder Benchmarks

```shell
$ npm run builder
```

## License

See [../README.md](../README.md#license)
5 changes: 5 additions & 0 deletions benchmark/XmlBuilder.js → benchmark/XmlBuilder.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ const suite = new Benchmark.Suite("XML Builder benchmark");
import {XMLBuilder} from "../src/fxp.js";
import xml2js from "xml2js";
const xml2jsBuilder = new xml2js.Builder();
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';

// compatibility
const __dirname = dirname(fileURLToPath(import.meta.url));

import fs from "fs";
import path from "path";
Expand Down
5 changes: 5 additions & 0 deletions benchmark/XmlParser.js → benchmark/XmlParser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import {XMLParser} from "../src/fxp.js";
import xml2js from "xml2js";
import fxpv3 from "fast-xml-parser";
import { convert } from 'xmlbuilder2';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';

// compatibility
const __dirname = dirname(fileURLToPath(import.meta.url));

const suite = new Benchmark.Suite("XML Parser benchmark");

Expand Down
4 changes: 3 additions & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"private": true,
"description": "Performance test",
"scripts": {
"perf": "node perfTest3.js"
"parser": "node XmlParser.mjs",
"builder": "node XmlBuilder.mjs",
"test": "npm run parser && npm run builder && node try.mjs"
},
"devDependencies": {
"benchmark": "^2.1.4",
Expand Down
7 changes: 6 additions & 1 deletion benchmark/try.js → benchmark/try.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import fs from "fs";
import path from "path";
// const fileNamePath = path.join(__dirname, "../spec/assets/test.json");//1.5k
// const jsonData = JSON.parse(fs.readFileSync(fileNamePath).toString());
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';

// compatibility
const __dirname = dirname(fileURLToPath(import.meta.url));


// const xml2js = require("xml2js");
Expand All @@ -16,4 +21,4 @@ const xmlData = fs.readFileSync(fileNamePath).toString();
const fxpParserForOrderedJs = new XMLParser({preserveOrder: true});
console.log(
JSON.stringify(fxpParserForOrderedJs.parse(xmlData), null, 4)
);
);
3 changes: 2 additions & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Here is the check list to publish any change
* Changes are well discussed by raising github issue. So they are well known by other contributors and users
* Echoing the above point. The purpose / goal for the PR should be mentioned in the description.
* Multiple unrelated changes should not be clubbed in single PR.
* Please run perf tests `$ node benchmark\XmlParser.js` or `$ node benchmark\XmlBuilder.js` before and after the changes. And mention it in PR description.
* Please run perf tests `$ node benchmark/XmlParser.mjs` or `$ node benchmark/XmlBuilder.mjs` before and after the changes. And mention it in PR description.
* See [benchmark/README.md](../benchmark/README.md) for details
* If you are adding any dependency (specially if it is not the dev dependency) please check that
* it is not dependent on other language packages like c/c++
* the package is not very old, very new, discontinued, or has any vulnerability etc.
Expand Down
Loading