Files
Luke SandbergandGitHub d85d3e2734 [turbopack] tweak the ui of the module-cost benchmark (#81817)
Have the module-cost benchmark page self identify and output into a text box to make copy-pasting the data out easier.
2025-07-29 10:46:55 -07:00

29 lines
693 B
JavaScript

export async function measure(name, fn) {
let module
let loadDuration
{
const start = performance.now()
module = await fn()
const end = performance.now()
loadDuration = end - start
}
let files
let executeDuration
{
const execute = module.execute
const start = performance.now()
files = execute()
const end = performance.now()
executeDuration = end - start
}
const result = { name, loadDuration, executeDuration, files }
return result
}
export function format(result) {
return `${result.name}: Load duration: ${result.loadDuration.toFixed(2)}ms, Execution duration: ${result.executeDuration.toFixed(2)}ms, Files: ${result.files}`
}