simpleperf/report_html.js
// nodes can be a CallNode, or an array of CallNodes with the same functionId.
nodes can be a CallNode, or an array of CallNodes with the same functionId.
nodes can be a CallNode or an array of CallNodes with the same functionId .
_renderSvgNodesWithSameRoot(nodes, depth, xOffset) {
        let x = xOffset;
        let y = this._getYForDepth(depth);
        let isArray = Array.isArray(nodes);
        let funcId;
        let sumCount;
        if (isArray) {
            funcId = nodes[0].f;
            sumCount = nodes.reduce((acc, cur) => acc + cur.s, 0);
        } else {
            funcId = nodes.f;
            sumCount = nodes.s;
        }
        let width = this._getWidthPercentage(sumCount);
        if (width < 0.1) {
            return xOffset;
        }
        let color = this._getHeatColor(width);
        let borderColor = {};
        for (let key in color) {
            borderColor[key] = Math.max(0, color[key] - 50);
        }
        let funcName = getFuncName(funcId);
        let libName = getLibNameOfFunction(funcId);
        let sampleWeight = this.sampleWeightFunction(sumCount, this.totalCount);
        let title = funcName + ' | ' + libName + ' (' + sumCount + ' events: ' +
                    sampleWeight + ')';
        this.svgStr.push(`<g><title>${title}</title> <rect x="${x}%" y="${y}" ox="${x}"
                        depth="${depth}" width="${width}%" owidth="${width}" height="15.0"
                        ofill="rgb(${color.r},${color.g},${color.b})"
                        fill="rgb(${color.r},${color.g},${color.b})"
                        style="stroke:rgb(${borderColor.r},${borderColor.g},${borderColor.b})"/>
                        <text x="${x}%" y="${y + 12}"></text></g>`);
        let children = isArray ? this._splitChildrenForNodes(nodes) : nodes.c;
        let childXOffset = xOffset;
        for (let child of children) {
            childXOffset = this._renderSvgNodesWithSameRoot(child, depth + 1, childXOffset);
        }
        return xOffset + width;
    }
_renderSvgNodesWithSameRoot ( nodes , depth , xOffset ) { let x = xOffset ; let y = this . _getYForDepth ( depth ) ; let isArray = Array . isArray ( nodes ) ; let funcId ; let sumCount ; if ( isArray ) { funcId = nodes [ 0 ] . f ; sumCount = nodes . reduce ( ( acc , cur ) => acc + cur . s , 0 ) ; } else { funcId = nodes . f ; sumCount = nodes . s ; } let width = this . _getWidthPercentage ( sumCount ) ; if ( width < 0.1 ) { return xOffset ; } let color = this . _getHeatColor ( width ) ; let borderColor = { } ; for ( let key in color ) { borderColor [ key ] = Math . max ( 0 , color [ key ] - 50 ) ; } let funcName = getFuncName ( funcId ) ; let libName = getLibNameOfFunction ( funcId ) ; let sampleWeight = this . sampleWeightFunction ( sumCount , this . totalCount ) ; let title = funcName + ' | ' + libName + ' (' + sumCount + ' events: ' + sampleWeight + ')' ; this . svgStr . push ( ` ${ title } ${ x } ${ y } ${ x } ${ depth } ${ width } ${ width } ${ color . r } ${ color . g } ${ color . b } ${ color . r } ${ color . g } ${ color . b } ${ borderColor . r } ${ borderColor . g } ${ borderColor . b } ${ x } ${ y + 12 } ` ) ; let children = isArray ? this . _splitChildrenForNodes ( nodes ) : nodes . c ; let childXOffset = xOffset ; for ( let child of children ) { childXOffset = this . _renderSvgNodesWithSameRoot ( child , depth + 1 , childXOffset ) ; } return xOffset + width ; }
nodes can be a CallNode, or an array of CallNodes with the same functionId.
nodes can be a CallNode or an array of CallNodes with the same functionId .