mirror of
https://github.com/jlfwong/speedscope.git
synced 2024-11-27 01:53:17 +03:00
7f7f5eeefb
This imports symbol maps generated by emscripten using the `--emit-symbol-map` flag. It allows you to visualize a profile captured in a release build as long as you also have the associated symbol map. To do this, first drop the profile into speedscope and then drop the symbol map. After the second drop, the symbols will be remapped to their original names. This is a fixed up version of #75
27 lines
929 B
TypeScript
27 lines
929 B
TypeScript
type AsmJsSymbolMap = Map<string, string>
|
|
|
|
// This imports symbol maps generated by emscripten using the "--emit-symbol-map" flag.
|
|
// It allows you to visualize a profile captured in a release build as long as you also
|
|
// have the associated symbol map. To do this, first drop the profile into speedscope
|
|
// and then drop the symbol map. After the second drop, the symbols will be remapped to
|
|
// their original names.
|
|
export function importAsmJsSymbolMap(contents: string): AsmJsSymbolMap | null {
|
|
const lines = contents.split('\n')
|
|
if (!lines.length) return null
|
|
|
|
// Remove a trailing blank line if there is one
|
|
if (lines[lines.length - 1] === '') lines.pop()
|
|
if (!lines.length) return null
|
|
|
|
const map: AsmJsSymbolMap = new Map()
|
|
const regex = /^([\$\w]+):([\$\w]+)$/
|
|
|
|
for (const line of lines) {
|
|
const match = regex.exec(line)
|
|
if (!match) return null
|
|
map.set(match[1], match[2])
|
|
}
|
|
|
|
return map
|
|
}
|