v8-deopt-webapp
v0.5.0
Published
View the deoptimizations in a V8 log
Downloads
21
Readme
v8-deopt-webapp
Display the V8 optimizations and deoptimizations of a JavaScript file
Installation
Check out
v8-deopt-viewer
for a CLI that automates this for you!
npm i v8-deopt-webapp
Usage
Generate a
PerFileDeoptInfoWithSources
object:Use
v8-deopt-generate-log
andv8-deopt-parser
to generate aV8DeoptInfo
object.Use the
groupByFile
utility fromv8-deopt-parser
to 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.css
anddist/v8-deopt-webapp.js
in 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:
cd
into this package's directory (e.g.packages/v8-deopt-webapp
)- Run
node test/generateTestData.mjs
- Open
test/index.html
in 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
.