Fix benchmark require (#4792)
parent
e9f489cea1
commit
6a6e8cada0
|
@ -200,11 +200,21 @@ function format(context, input, opt) {
|
||||||
return { formatted: pp, filepath: opt.filepath || "(stdin)\n" };
|
return { formatted: pp, filepath: opt.filepath || "(stdin)\n" };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* istanbul ignore if */
|
||||||
if (context.argv["debug-benchmark"]) {
|
if (context.argv["debug-benchmark"]) {
|
||||||
|
let benchmark;
|
||||||
|
try {
|
||||||
|
benchmark = eval("require")("benchmark");
|
||||||
|
} catch (err) {
|
||||||
|
context.logger.debug(
|
||||||
|
"'--debug-benchmark' requires the 'benchmark' package to be installed."
|
||||||
|
);
|
||||||
|
process.exit(2);
|
||||||
|
}
|
||||||
context.logger.debug(
|
context.logger.debug(
|
||||||
"'--debug-benchmark' option found, measuring formatWithCursor with 'benchmark' module."
|
"'--debug-benchmark' option found, measuring formatWithCursor with 'benchmark' module."
|
||||||
);
|
);
|
||||||
const suite = new require("benchmark").Suite();
|
const suite = new benchmark.Suite();
|
||||||
suite
|
suite
|
||||||
.add("format", () => {
|
.add("format", () => {
|
||||||
prettier.formatWithCursor(input, opt);
|
prettier.formatWithCursor(input, opt);
|
||||||
|
|
Loading…
Reference in New Issue