mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +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) {
|
||||
const content = await readFile(file, "utf8");
|
||||
consoleLogTokens(parse(content));
|
||||
const results = await markdownlint({
|
||||
"files": [ file ]
|
||||
});
|
||||
console.dir(results, { "depth": null });
|
||||
if (!profile) {
|
||||
const content = await readFile(file, "utf8");
|
||||
consoleLogTokens(parse(content));
|
||||
}
|
||||
let results = null;
|
||||
performance.mark("profile-start");
|
||||
for (let i = 0; i < count; i++) {
|
||||
results = await markdownlint({
|
||||
"files": [ file ]
|
||||
});
|
||||
}
|
||||
const measure = performance.measure("profile", "profile-start");
|
||||
if (profile) {
|
||||
console.log(Math.round(measure.duration));
|
||||
} else {
|
||||
console.dir(results, { "depth": null });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue