simpleperf/report_html.js
// Return a promise to draw flamegraphs.
Return a promise to draw flamegraphs.
Return a promise to draw flamegraphs .
_drawMoreFlameGraphs(moreCount, progress) {
        let initProgress = progress / (1 + moreCount);
        let newFlamegraphs = [];
        return createPromise()
        .then(wait(() => {
            if (this.moreButton) {
                this.moreButton.hide();
            }
            let pId = 0;
            let tId = 0;
            let newCount = this.flamegraphs.length + moreCount;
            for (let i = 0; i < newCount; ++i) {
                if (pId == this.eventInfo.processes.length) {
                    break;
                }
                let process = this.eventInfo.processes[pId];
                let thread = process.threads[tId];
                if (i >= this.flamegraphs.length) {
                    let title = `Process ${getProcessName(process.pid)} ` +
                                `Thread ${getThreadName(thread.tid)} ` +
                                `(Samples: ${thread.sampleCount})`;
                    let totalCount = {countForProcess: process.eventCount,
                                      countForThread: thread.eventCount};
                    let flamegraph = new FlameGraphView(this.flamegraphDiv, title, totalCount,
                                                        thread.g.c, false);
                    flamegraph.draw();
                    newFlamegraphs.push(flamegraph);
                }
                tId++;
                if (tId == process.threads.length) {
                    pId++;
                    tId = 0;
                }
            }
            if (pId < this.eventInfo.processes.length) {
                if (!this.moreButton) {
                    this.div.append(`
                        <div style="text-align:center">
                            <button type="button" class="btn btn-primary">More</button>
                        </div>`);
                    this.moreButton = this.div.children().last().find('button');
                    this.moreButton.click(() => {
                        createPromise().then(updateProgress('Draw FlameGraph...', 0))
                            .then(() => this._drawMoreFlameGraphs(10, 100))
                            .then(hideProgress());
                    });
                    this.moreButton.hide();
                }
            } else if (this.moreButton) {
                this.moreButton.remove();
                this.moreButton = null;
            }
            for (let flamegraph of newFlamegraphs) {
                this.flamegraphs.push(flamegraph);
            }
        }))
        .then(addProgress(initProgress))
        .then(() => this.drawDetails(newFlamegraphs, progress - initProgress));
    }
_drawMoreFlameGraphs ( moreCount , progress ) { let initProgress = progress / ( 1 + moreCount ) ; let newFlamegraphs = [ ] ; return createPromise ( ) . then ( wait ( ( ) => { if ( this . moreButton ) { this . moreButton . hide ( ) ; } let pId = 0 ; let tId = 0 ; let newCount = this . flamegraphs . length + moreCount ; for ( let i = 0 ; i < newCount ; ++ i ) { if ( pId == this . eventInfo . processes . length ) { break ; } let process = this . eventInfo . processes [ pId ] ; let thread = process . threads [ tId ] ; if ( i >= this . flamegraphs . length ) { let title = ` ${ getProcessName ( process . pid ) } ` + ` ${ getThreadName ( thread . tid ) } ` + ` ${ thread . sampleCount } ` ; let totalCount = { countForProcess : process . eventCount , countForThread : thread . eventCount } ; let flamegraph = new FlameGraphView ( this . flamegraphDiv , title , totalCount , thread . g . c , false ) ; flamegraph . draw ( ) ; newFlamegraphs . push ( flamegraph ) ; } tId ++ ; if ( tId == process . threads . length ) { pId ++ ; tId = 0 ; } } if ( pId < this . eventInfo . processes . length ) { if ( ! this . moreButton ) { this . div . append ( ` ` ) ; this . moreButton = this . div . children ( ) . last ( ) . find ( 'button' ) ; this . moreButton . click ( ( ) => { createPromise ( ) . then ( updateProgress ( 'Draw FlameGraph...' , 0 ) ) . then ( ( ) => this . _drawMoreFlameGraphs ( 10 , 100 ) ) . then ( hideProgress ( ) ) ; } ) ; this . moreButton . hide ( ) ; } } else if ( this . moreButton ) { this . moreButton . remove ( ) ; this . moreButton = null ; } for ( let flamegraph of newFlamegraphs ) { this . flamegraphs . push ( flamegraph ) ; } } ) ) . then ( addProgress ( initProgress ) ) . then ( ( ) => this . drawDetails ( newFlamegraphs , progress - initProgress ) ) ; }
Return a promise to draw flamegraphs.
Return a promise to draw flamegraphs .
// Show "More" Button.