simpleperf/report_html.js
// Return a list of SourceFile related to a function.
Return a list of SourceFile related to a function.
Return a list of SourceFile related to a function .
function collectSourceFilesForFunction(func) {
    if (!func.hasOwnProperty('s')) {
        return null;
    }
    let hitLines = func.s;
    let sourceFiles = {};  
    function getFile(fileId) {
        let file = sourceFiles[fileId];
        if (!file) {
            file = sourceFiles[fileId] = new SourceFile(fileId);
        }
        return file;
    }
    let funcRange = getFuncSourceRange(func.f);
    if (funcRange) {
        let file = getFile(funcRange.fileId);
        file.addLineRange(funcRange.startLine);
    }
    for (let hitLine of hitLines) {
        let file = getFile(hitLine.f);
        file.addLineRange(hitLine.l - 5, hitLine.l + 5);
        file.addLineCount(hitLine.l, hitLine.e, hitLine.s);
    }
    let result = [];
    if (funcRange) {
        let file = getFile(funcRange.fileId);
        if (file.hasCount) {
            result.push(file);
        }
        delete sourceFiles[funcRange.fileId];
    }
    for (let fileId in sourceFiles) {
        let file = sourceFiles[fileId];
        if (file.hasCount) {
            result.push(file);
        }
    }
    return result.length > 0 ? result : null;
}
function collectSourceFilesForFunction ( func ) { if ( ! func . hasOwnProperty ( 's' ) ) { return null ; } let hitLines = func . s ; let sourceFiles = { } ; function getFile ( fileId ) { let file = sourceFiles [ fileId ] ; if ( ! file ) { file = sourceFiles [ fileId ] = new SourceFile ( fileId ) ; } return file ; } let funcRange = getFuncSourceRange ( func . f ) ; if ( funcRange ) { let file = getFile ( funcRange . fileId ) ; file . addLineRange ( funcRange . startLine ) ; } for ( let hitLine of hitLines ) { let file = getFile ( hitLine . f ) ; file . addLineRange ( hitLine . l - 5 , hitLine . l + 5 ) ; file . addLineCount ( hitLine . l , hitLine . e , hitLine . s ) ; } let result = [ ] ; if ( funcRange ) { let file = getFile ( funcRange . fileId ) ; if ( file . hasCount ) { result . push ( file ) ; } delete sourceFiles [ funcRange . fileId ] ; } for ( let fileId in sourceFiles ) { let file = sourceFiles [ fileId ] ; if ( file . hasCount ) { result . push ( file ) ; } } return result . length > 0 ? result : null ; }
Return a list of SourceFile related to a function.
Return a list of SourceFile related to a function .
// map from sourceFileId to SourceFile. // Show lines for the function. // Show lines for hitLines. // Show the source file containing the function before other source files.