feat(web): writes profile logs to file, outputs within new /web/build/profiling folder

This commit is contained in:
Joshua A. Horton 2023-05-31 15:51:50 +07:00
parent c7be7a1bcb
commit 5e93bb0189
3 changed files with 29 additions and 14 deletions

View file

@ -109,19 +109,24 @@ const embeddedWorkerBuildOptions = {
// Direct-use version
await esbuild.build(embeddedWorkerBuildOptions);
// We want a specialized bundle build here instead; no output, but minified like
// the actual release worker.
const minifiedProfilingOptions = {
...embeddedWorkerBuildOptions,
minify: true,
metafile: true,
write: false // don't actually write the file.
}
let result = await esbuild.build(minifiedProfilingOptions);
let filesizeProfile = await esbuild.analyzeMetafile(result.metafile, { verbose: true });
fs.writeFileSync('build/filesize-profile.log', `
// Minified Worker filesize profile, before polyfilling
${filesizeProfile}
`);
if(EMIT_FILESIZE_PROFILE) {
// We want a specialized bundle build here instead; no output, but minified like
// the actual worker.
const minifiedProfilingOptions = {
...embeddedWorkerBuildOptions,
minify: true,
metafile: true,
write: false // don't actually write the file.
}
let result = await esbuild.build(minifiedProfilingOptions);
console.log("Minified, pre-polyfill worker filesize profile:");
// Profiles the sourcecode!
console.log(await esbuild.analyzeMetafile(result.metafile, { verbose: true }));
console.log(filesizeProfile);
}

View file

@ -82,12 +82,17 @@ let result = await esbuild.build({
treeShaking: true,
tsconfig: './tsconfig.json',
// Enables source-file output size profiling!
metafile: EMIT_FILESIZE_PROFILE
metafile: true
});
let filesizeProfile = await esbuild.analyzeMetafile(result.metafile, { verbose: true });
fs.writeFileSync('../../../build/app/browser/filesize-profile.log', `
// Minified Keyman Engine for Web ('app/browser' target), filesize profile
${filesizeProfile}
`);
if(EMIT_FILESIZE_PROFILE) {
// Profiles the sourcecode!
console.log(await esbuild.analyzeMetafile(result.metafile, { verbose: true }));
console.log(filesizeProfile);
}
await esbuild.build({

View file

@ -52,6 +52,11 @@ compile_and_copy() {
# Update the build/publish copy of our build artifacts
prepare
local PROFILE_DEST="$KEYMAN_ROOT/web/build/profiling/"
mkdir -p "$PROFILE_DEST"
cp "$KEYMAN_ROOT/web/build/app/browser/filesize-profile.log" "$PROFILE_DEST/web-engine-filesize.log"
cp "$KEYMAN_ROOT/common/web/lm-worker/build/filesize-profile.log" "$PROFILE_DEST/lm-worker-filesize.log"
}
builder_run_action configure verify_npm_setup