Skip to content

Commit

Permalink
improve performance (#165)
Browse files Browse the repository at this point in the history
* improve performance

* Create gentle-windows-visit.md
  • Loading branch information
ota-meshi committed Nov 8, 2023
1 parent fd33c7d commit 475b9c5
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 183 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-windows-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"toml-eslint-parser": minor
---

improve performance
26 changes: 7 additions & 19 deletions benchmark/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import fs from "fs";
import path from "path";
import { parseForESLint } from "..";
import { parseForESLint as parseOld } from "../node_modules/toml-eslint-parser";
import { parse as parseByIarna } from "@iarna/toml";

const contents = `${fs.readFileSync(
path.resolve(
Expand Down Expand Up @@ -51,28 +52,15 @@ function onComplete(): void {

const suite = new Benchmark.Suite("benchmark", { onCycle, onComplete });

for (const no of [1, 2, 3]) {
for (const no of [1, 2, 3, 4, 5]) {
suite.add(`${no} new toml-eslint-parser`, function () {
parseForESLint(contents, {
loc: true,
range: true,
raw: true,
tokens: true,
comment: true,
eslintVisitorKeys: true,
eslintScopeManager: true,
});
parseForESLint(contents, {});
});
suite.add(`${no} old toml-eslint-parser`, function () {
parseOld(contents, {
loc: true,
range: true,
raw: true,
tokens: true,
comment: true,
eslintVisitorKeys: true,
eslintScopeManager: true,
});
parseOld(contents, {});
});
suite.add(`${no} @iarna/toml `, function () {
parseByIarna(contents);
});
}

Expand Down

0 comments on commit 475b9c5

Please sign in to comment.