simpleperf/report_html.js
// Return a promise to draw SampleTable.
Return a promise to draw SampleTable.
Return a promise to draw SampleTable .
_drawSampleTable(totalProgress) {
        let eventInfo = this.eventInfo;
        let data = [];
        return createPromise()
            .then(wait(() => {
                this.tableDiv.empty();
                let getSampleWeight = this.selectorView.getSampleWeightFunction();
                let sampleWeightSuffix = this.selectorView.getSampleWeightSuffix();
                let valueSuffix = sampleWeightSuffix.length > 0 ? `(in${sampleWeightSuffix})` : '';
                let titles = ['Total' + valueSuffix, 'Self' + valueSuffix, 'Samples', 'Process',
                              'Thread', 'Library', 'Function', 'HideKey'];
                this.tableDiv.append(`
                    <table cellspacing="0" class="table table-striped table-bordered"
                        style="width:100%">
                        <thead>${getTableRow(titles, 'th')}</thead>
                        <tbody></tbody>
                        <tfoot>${getTableRow(titles, 'th')}</tfoot>
                    </table>`);
                for (let [i, process] of eventInfo.processes.entries()) {
                    let processName = getProcessName(process.pid);
                    for (let [j, thread] of process.threads.entries()) {
                        let threadName = getThreadName(thread.tid);
                        for (let [k, lib] of thread.libs.entries()) {
                            let libName = getLibName(lib.libId);
                            for (let [t, func] of lib.functions.entries()) {
                                let totalValue = getSampleWeight(func.c[2]);
                                let selfValue = getSampleWeight(func.c[1]);
                                let key = [i, j, k, t].join('_');
                                data.push([totalValue, selfValue, func.c[0], processName,
                                           threadName, libName, getFuncName(func.f), key])
                           }
                        }
                    }
                }
            }))
            .then(addProgress(totalProgress / 2))
            .then(wait(() => {
                let table = this.tableDiv.find('table');
                let dataTable = table.DataTable({
                    lengthMenu: [10, 20, 50, 100, -1],
                    order: [0, 'desc'],
                    data: data,
                    responsive: true,
                });
                dataTable.column(7).visible(false);
                table.find('tr').css('cursor', 'pointer');
                table.on('click', 'tr', function() {
                    let data = dataTable.row(this).data();
                    if (!data) {
                        return;
                    }
                    let key = data[7];
                    if (!key) {
                        return;
                    }
                    let indexes = key.split('_');
                    let processInfo = eventInfo.processes[indexes[0]];
                    let threadInfo = processInfo.threads[indexes[1]];
                    let lib = threadInfo.libs[indexes[2]];
                    let func = lib.functions[indexes[3]];
                    FunctionTab.showFunction(eventInfo, processInfo, threadInfo, lib, func);
                });
            }));
    }
_drawSampleTable ( totalProgress ) { let eventInfo = this . eventInfo ; let data = [ ] ; return createPromise ( ) . then ( wait ( ( ) => { this . tableDiv . empty ( ) ; let getSampleWeight = this . selectorView . getSampleWeightFunction ( ) ; let sampleWeightSuffix = this . selectorView . getSampleWeightSuffix ( ) ; let valueSuffix = sampleWeightSuffix . length > 0 ? ` ${ sampleWeightSuffix } ` : '' ; let titles = [ 'Total' + valueSuffix , 'Self' + valueSuffix , 'Samples' , 'Process' , 'Thread' , 'Library' , 'Function' , 'HideKey' ] ; this . tableDiv . append ( ` ${ getTableRow ( titles , 'th' ) } ${ getTableRow ( titles , 'th' ) } ` ) ; for ( let [ i , process ] of eventInfo . processes . entries ( ) ) { let processName = getProcessName ( process . pid ) ; for ( let [ j , thread ] of process . threads . entries ( ) ) { let threadName = getThreadName ( thread . tid ) ; for ( let [ k , lib ] of thread . libs . entries ( ) ) { let libName = getLibName ( lib . libId ) ; for ( let [ t , func ] of lib . functions . entries ( ) ) { let totalValue = getSampleWeight ( func . c [ 2 ] ) ; let selfValue = getSampleWeight ( func . c [ 1 ] ) ; let key = [ i , j , k , t ] . join ( '_' ) ; data . push ( [ totalValue , selfValue , func . c [ 0 ] , processName , threadName , libName , getFuncName ( func . f ) , key ] ) } } } } } ) ) . then ( addProgress ( totalProgress / 2 ) ) . then ( wait ( ( ) => { let table = this . tableDiv . find ( 'table' ) ; let dataTable = table . DataTable ( { lengthMenu : [ 10 , 20 , 50 , 100 , - 1 ] , order : [ 0 , 'desc' ] , data : data , responsive : true , } ) ; dataTable . column ( 7 ) . visible ( false ) ; table . find ( 'tr' ) . css ( 'cursor' , 'pointer' ) ; table . on ( 'click' , 'tr' , function ( ) { let data = dataTable . row ( this ) . data ( ) ; if ( ! data ) { return ; } let key = data [ 7 ] ; if ( ! key ) { return ; } let indexes = key . split ( '_' ) ; let processInfo = eventInfo . processes [ indexes [ 0 ] ] ; let threadInfo = processInfo . threads [ indexes [ 1 ] ] ; let lib = threadInfo . libs [ indexes [ 2 ] ] ; let func = lib . functions [ indexes [ 3 ] ] ; FunctionTab . showFunction ( eventInfo , processInfo , threadInfo , lib , func ) ; } ) ; } ) ) ; }
Return a promise to draw SampleTable.
Return a promise to draw SampleTable .
// Draw a table of 'Total', 'Self', 'Samples', 'Process', 'Thread', 'Library', // 'Function'. // A row in header or footer.