mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-12 14:00:01 -04:00
add overhead measurement
This commit is contained in:
parent
6cec47b891
commit
c54929198d
2 changed files with 5 additions and 4 deletions
|
@ -25,6 +25,7 @@ function rewriteJsWrapper(
|
|||
meta: URLMeta
|
||||
): string | ArrayBuffer {
|
||||
let out: RewriterOutput;
|
||||
const before = performance.now();
|
||||
if (typeof input === "string") {
|
||||
out = rewrite_js(input, meta.base.href, url || "(unknown)", $scramjet);
|
||||
} else {
|
||||
|
@ -35,16 +36,15 @@ function rewriteJsWrapper(
|
|||
$scramjet
|
||||
);
|
||||
}
|
||||
const after = performance.now();
|
||||
const { js, errors, duration } = out;
|
||||
|
||||
// TODO: maybe make this a scram flag?
|
||||
if (flagEnabled("rewriterLogs", meta.base)) {
|
||||
for (const error of errors) {
|
||||
console.error("oxc parse error", error);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: maybe make this a scram flag?
|
||||
if (flagEnabled("rewriterLogs", meta.base)) {
|
||||
let timespan: string;
|
||||
if (duration < 1n) {
|
||||
|
@ -54,8 +54,9 @@ function rewriteJsWrapper(
|
|||
} else {
|
||||
timespan = "really slow";
|
||||
}
|
||||
const overhead = (after - before - Number(duration)).toFixed(2);
|
||||
console.log(
|
||||
`oxc rewrite for "${url || "(unknown)"}" was ${timespan} (${duration}ms)`
|
||||
`oxc rewrite for "${url || "(unknown)"}" was ${timespan} (${duration}ms; ${overhead}ms overhead)`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue