@@ -1063,11 +1063,7 @@ function populateStats(data) {
10631063 funcname = funcname || 'unknown' ;
10641064
10651065 if ( filename !== 'unknown' && funcname !== 'unknown' && node . value > 0 ) {
1066- let childrenValue = 0 ;
1067- if ( node . children ) {
1068- childrenValue = node . children . reduce ( ( sum , child ) => sum + child . value , 0 ) ;
1069- }
1070- const directSamples = Math . max ( 0 , node . value - childrenValue ) ;
1066+ const directSamples = node . self || 0 ;
10711067
10721068 const funcKey = `${ filename } :${ node . lineno || '?' } :${ funcname } ` ;
10731069
@@ -1345,14 +1341,13 @@ function processLeaf(invertedRoot, path, leafNode, isDifferential) {
13451341}
13461342
13471343function traverseInvert ( path , currentNode , invertedRoot , isDifferential ) {
1348- const children = currentNode . children || [ ] ;
1349- const childThreads = new Set ( children . flatMap ( c => c . threads || [ ] ) ) ;
1350- const selfThreads = ( currentNode . threads || [ ] ) . filter ( t => ! childThreads . has ( t ) ) ;
1344+ const selfValue = currentNode . self || 0 ;
13511345
1352- if ( selfThreads . length > 0 ) {
1353- processLeaf ( invertedRoot , path , { ...currentNode , threads : selfThreads } , isDifferential ) ;
1346+ if ( selfValue > 0 ) {
1347+ processLeaf ( invertedRoot , path , { ...currentNode , value : selfValue } , isDifferential ) ;
13541348 }
13551349
1350+ const children = currentNode . children || [ ] ;
13561351 children . forEach ( child => traverseInvert ( path . concat ( [ child ] ) , child , invertedRoot , isDifferential ) ) ;
13571352}
13581353
0 commit comments