Skip to content

Commit f67d06d

Browse files
committed
chore: add performance mark on debug
1 parent e68e4d2 commit f67d06d

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

Diff for: src/biome.ts

-4
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,10 @@ export const biomeLintFiles = (
128128
biome: Biome,
129129
files: string[],
130130
fix = true,
131-
debug = false,
132131
) => {
133132
const results = [];
134133

135134
for (const file of files) {
136-
if (debug) {
137-
console.debug(`Linting ${file}`);
138-
}
139135
const result = biomeLintFile(biome, file, fix);
140136

141137
results.push(result);

Diff for: src/index.ts

+26-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { mergeResults, overrideConfig } from "./eslint";
77
import pkgJson from "../package.json" assert { type: "json" };
88
import yargs from "yargs";
99
import { hideBin } from "yargs/helpers";
10+
import { performance } from "node:perf_hooks";
1011

1112
const instance = yargs(hideBin(process.argv))
1213
.scriptName("@nivalis/linter")
@@ -57,8 +58,16 @@ const instance = yargs(hideBin(process.argv))
5758
overrideConfig: eslintOnly ? [] : overrideConfig,
5859
});
5960

61+
if (debug) {
62+
performance.mark("eslint-start");
63+
}
6064
const eslintResults = await eslint.lintFiles(files);
6165

66+
if (debug) {
67+
performance.mark("eslint-end");
68+
performance.measure("eslint", "eslint-start", "eslint-end");
69+
}
70+
6271
if (fix && eslintResults.length > 0) {
6372
await ESLint.outputFixes(eslintResults);
6473
}
@@ -84,12 +93,28 @@ const instance = yargs(hideBin(process.argv))
8493

8594
biome.applyConfiguration(getBiomeConfig());
8695

87-
const biomeResults = biomeLintFiles(biome, allFiles, fix, debug);
96+
if (debug) {
97+
performance.mark("biome-start");
98+
}
99+
100+
const biomeResults = biomeLintFiles(biome, allFiles, fix);
101+
102+
if (debug) {
103+
performance.mark("biome-end");
104+
performance.measure("biome", "biome-start", "biome-end");
105+
}
88106

89107
const resultText = await formatter.format(
90108
mergeResults([...biomeResults, ...eslintResults]),
91109
);
92110

111+
if (debug) {
112+
const measurements = performance.getEntriesByType("measure");
113+
for (const measurement of measurements) {
114+
console.log(`${measurement.name}: ${measurement.duration}ms`);
115+
}
116+
}
117+
93118
console.log(resultText ? resultText : "No issues found");
94119
} catch (error) {
95120
console.error(error);

0 commit comments

Comments
 (0)