mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Add --profile argument to harness.mjs for measuring and reporting elapsed time.
This commit is contained in:
parent
3099a98b51
commit
87fda39df8
1 changed files with 28 additions and 7 deletions
|
|
@ -24,12 +24,33 @@ function consoleLogTokens(tokens, depth = 0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = process.argv.slice(2);
|
let profile = false;
|
||||||
|
let count = 1;
|
||||||
|
const files = process.argv.slice(2).filter((arg) => {
|
||||||
|
if (arg === "--profile") {
|
||||||
|
profile = true;
|
||||||
|
count = 1000;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
|
if (!profile) {
|
||||||
const content = await readFile(file, "utf8");
|
const content = await readFile(file, "utf8");
|
||||||
consoleLogTokens(parse(content));
|
consoleLogTokens(parse(content));
|
||||||
const results = await markdownlint({
|
}
|
||||||
|
let results = null;
|
||||||
|
performance.mark("profile-start");
|
||||||
|
for (let i = 0; i < count; i++) {
|
||||||
|
results = await markdownlint({
|
||||||
"files": [ file ]
|
"files": [ file ]
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
const measure = performance.measure("profile", "profile-start");
|
||||||
|
if (profile) {
|
||||||
|
console.log(Math.round(measure.duration));
|
||||||
|
} else {
|
||||||
console.dir(results, { "depth": null });
|
console.dir(results, { "depth": null });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue