v8-deopt-webapp
v0.5.0
Published
View the deoptimizations in a V8 log
Readme
v8-deopt-webapp
Display the V8 optimizations and deoptimizations of a JavaScript file
Installation
Check out
v8-deopt-viewerfor a CLI that automates this for you!
npm i v8-deopt-webappUsage
Generate a
PerFileDeoptInfoWithSourcesobject:Use
v8-deopt-generate-logandv8-deopt-parserto generate aV8DeoptInfoobject.Use the
groupByFileutility fromv8-deopt-parserto group the results by file.Extend the resulting object with the source of each file listed, and the shortened relative path to that file (can be defined relative to whatever you like)
import { parseV8Log, groupByFile } from "v8-deopt-parser"; const rawDeoptInfo = await parseV8Log(logContents); const groupDeoptInfo = groupByFile(rawDeoptInfo); const deoptInfo = { ...groupDeoptInfo, // Define some addSources function that adds the `src` and `relativePath` property // to each file object in groupDeoptInfo.files files: await addSources(groupDeoptInfo.files), };
Include the object in an HTML file
Include
dist/v8-deopt-webapp.cssanddist/v8-deopt-webapp.jsin the HTML fileCall
V8DeoptViewer.renderIntoDom(object, container)with the object and the DOM Node you want the app to render into
Currently, we only produce a UMD build, but would consider publishing an ESM build if it's useful to people
Contributing
See the Contributing.md guide at the root of the repo for general guidance you should follow.
To run the webapp locally:
cdinto this package's directory (e.g.packages/v8-deopt-webapp)- Run
node test/generateTestData.mjs - Open
test/index.htmlin your favorite web browser
By default, the test page (test/index.html) loads the data from test/deoptInfo.js. If you want to simulate a log that doesn't have sources, add ?error to the URL to load deoptInfoError.js.
If you make changes to v8-deopt-generate-log or v8-deopt-parser, you'll need to rerun generateTestData.mjs to re-generate deoptInfo.js & deoptInfoError.js.
