Skip to content

Commit 01fdc75

Browse files
slonkaKrzysztof Slonka
authored and
Krzysztof Slonka
committed
Disable Merge/Unmerge Optimized Unoptimized buttons when generating flamegraph from v8 profile
1 parent d16e062 commit 01fdc75

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async function zeroEks (args) {
2626
}
2727

2828
validate(args)
29-
const { collectOnly, visualizeOnly, writeTicks, treeDebug, mapFrames } = args
29+
const { collectOnly, visualizeOnly, writeTicks, treeDebug, mapFrames, visualizeV8Profile } = args
3030

3131
let incompatibleOptions = 0
3232
if (collectOnly) incompatibleOptions += 1
@@ -38,7 +38,7 @@ async function zeroEks (args) {
3838
}
3939

4040
if (visualizeOnly) return visualize(args)
41-
if (visualizeV8Profile) return visualizeV8Profile(args)
41+
if (visualizeV8Profile) return v8ProfileVisualization(args)
4242

4343
args.title = args.title || `node ${args.argv.join(' ')}`
4444
var { ticks, pid, folder, inlined } = await startProcessAndCollectTraceData(args)
@@ -111,7 +111,7 @@ function getFolder (file, workingDir) {
111111
: file
112112
}
113113

114-
async function visualizeV8Profile (opts) {
114+
async function v8ProfileVisualization (opts) {
115115
const folder = dirname(opts.visualizeV8Profile)
116116
const file = await render({ ...opts, folder })
117117
return file

lib/render.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async function render (opts) {
2929

3030
const script = `
3131
${await createBundle()}
32-
visualizer(${JSON.stringify(trees)}, ${JSON.stringify({ title, kernelTracing })})
32+
visualizer(${JSON.stringify(trees)}, ${JSON.stringify({ title, kernelTracing, visualizeV8Profile })})
3333
`
3434
const htmlPath = determineHtmlPath({ name, outputHtml, workingDir, pid, outputDir: folder })
3535

visualizer/cmp/controls.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
'use strict'
22

33
const button = (render) => ({ label, pressed, disabled, width }, action) => render`
4-
<button
4+
<button
55
class="f6 pointer br2 ba ph3 pv1 dib black mb2 mt1 ml1 mr1 ${disabled ? 'o-50 bg-silver' : ''}"
66
${disabled ? 'disabled' : ''}
77
style="
88
${pressed ? 'box-shadow: 0 0 0 .125em black;' : ''}
99
${width ? 'width: ' + width + ';' : ''}
10-
"
10+
"
1111
onclick=${action}
1212
>
1313
${label}
@@ -16,17 +16,17 @@ const button = (render) => ({ label, pressed, disabled, width }, action) => rend
1616

1717
module.exports = (render) => (state, action) => {
1818
const tiers = button(render)({ label: 'Tiers', pressed: state.tiers }, () => action({ type: 'tiers' }))
19-
const view = state.renderMergedBtn ? button(render)({
19+
const view = state.renderMergedBtn && !state.visualizeV8Profile ? button(render)({
2020
label: state.merged ? 'Unmerge' : 'Merge',
2121
width: '6.85em',
2222
pressed: state.merged
2323
}, () => action({ type: 'view' })) : ''
24-
const optimized = button(render)({
24+
const optimized = state.visualizeV8Profile ? '' : button(render)({
2525
label: 'Optimized',
2626
pressed: !state.merged && state.optimized,
2727
disabled: state.merged
2828
}, () => action({ type: 'optimized' }))
29-
const unoptimized = button(render)({
29+
const unoptimized = state.visualizeV8Profile ? '' : button(render)({
3030
label: 'Unoptimized',
3131
pressed: !state.merged && state.unoptimized,
3232
disabled: state.merged

visualizer/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const ui = require('./cmp/ui')(render)
1010

1111
module.exports = function (trees, opts) {
1212
opts = opts || {}
13-
const { kernelTracing } = opts
13+
const { kernelTracing, visualizeV8Profile } = opts
1414
const exclude = new Set(['cpp', 'regexp', 'v8', 'native', 'init'])
1515

1616
const chart = graph()
@@ -49,7 +49,7 @@ module.exports = function (trees, opts) {
4949
flamegraph.width(width).update()
5050
}, 150))
5151

52-
const state = createState({ colors, trees, exclude, kernelTracing, title: opts.title })
52+
const state = createState({ colors, trees, exclude, kernelTracing, title: opts.title, visualizeV8Profile })
5353

5454
const actions = createActions({ flamegraph, state }, (state) => {
5555
morphdom(iface, ui({ state, actions }))

visualizer/state.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const hsl = require('hsl-to-rgb-for-reals')
44
const { colorHash } = require('d3-fg')
55

6-
module.exports = ({ colors, trees, exclude, merged = false, kernelTracing, title }) => ({
6+
module.exports = ({ colors, trees, exclude, merged = false, kernelTracing, title, visualizeV8Profile }) => ({
77
trees,
88
focusedNodeId: null,
99
key: {
@@ -21,6 +21,7 @@ module.exports = ({ colors, trees, exclude, merged = false, kernelTracing, title
2121
optimized: false,
2222
unoptimized: false,
2323
renderMergedBtn: !kernelTracing,
24+
visualizeV8Profile,
2425
merged: merged
2526
},
2627
typeFilters: {

0 commit comments

Comments
 (0)