@@ -23,7 +23,7 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
2323 /**
2424 * @param {!Protocol.Profiler.Profile } profile
2525 */
26- public constructor ( profile : Profile ) {
26+ public constructor ( profile : Profile ) {
2727 super ( )
2828 const isLegacyFormat = ! ! profile [ 'head' ]
2929
@@ -58,18 +58,18 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
5858 /**
5959 * @param {!Protocol.Profiler.Profile } profile
6060 */
61- private _compatibilityConversionHeadToNodes ( profile : Profile ) : void {
61+ private _compatibilityConversionHeadToNodes ( profile : Profile ) : void {
6262 /** @type {!Array<!Protocol.Profiler.ProfileNode> } */
6363 const nodes : ProfileNode [ ] = [ ]
6464
6565 /**
6666 * @param {!Protocol.Profiler.ProfileNode } node
6767 * @return {number }
6868 */
69- function convertNodesTree ( node : ProfileNode ) : number {
70- nodes . push ( node ) ;
69+ function convertNodesTree ( node : ProfileNode ) : number {
70+ nodes . push ( node )
7171 // TODO(Christian) fix typings
72- ( node . children as unknown as number [ ] ) = node . children . map ( convertNodesTree )
72+ ; ( node . children as unknown as number [ ] ) = node . children . map ( convertNodesTree )
7373 return node . id
7474 }
7575
@@ -86,7 +86,7 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
8686 * @param {!Protocol.Profiler.Profile } profile
8787 * @return {?Array<number> }
8888 */
89- private _convertTimeDeltas ( profile : Profile ) : number [ ] {
89+ private _convertTimeDeltas ( profile : Profile ) : number [ ] {
9090 if ( ! profile . timeDeltas ) {
9191 return null
9292 }
@@ -106,14 +106,14 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
106106 * @param {!Array<!Protocol.Profiler.ProfileNode> } nodes
107107 * @return {!CPUProfileNode }
108108 */
109- private _translateProfileTree ( nodes : ProfileNode [ ] ) : CPUProfileNode {
109+ private _translateProfileTree ( nodes : ProfileNode [ ] ) : CPUProfileNode {
110110 /** @type {!Map<number, !Protocol.Profiler.ProfileNode> } */
111111 const nodeByIdMap : Map < number , ProfileNode > = new Map ( )
112112
113113 /**
114114 * @param {!Array<!Protocol.Profiler.ProfileNode> } nodes
115115 */
116- function buildChildrenFromParents ( nodes : ProfileNode [ ] ) : void {
116+ function buildChildrenFromParents ( nodes : ProfileNode [ ] ) : void {
117117 if ( nodes [ 0 ] . children ) {
118118 return
119119 }
@@ -122,12 +122,12 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
122122 for ( let i = 1 ; i < nodes . length ; ++ i ) {
123123 const node = nodes [ i ]
124124 // TODO(Christian) fix typings
125- const parentNode = nodeByIdMap . get ( ( node . parent as unknown as number ) )
125+ const parentNode = nodeByIdMap . get ( node . parent as unknown as number )
126126 // TODO(Christian) fix typings
127127 if ( parentNode . children ) {
128- ( parentNode . children as unknown as number [ ] ) . push ( node . id )
128+ ; ( parentNode . children as unknown as number [ ] ) . push ( node . id )
129129 } else {
130- ( parentNode . children as unknown as number [ ] ) = [ node . id ]
130+ ; ( parentNode . children as unknown as number [ ] ) = [ node . id ]
131131 }
132132 }
133133 }
@@ -136,15 +136,18 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
136136 * @param {!Array<!Protocol.Profiler.ProfileNode> } nodes
137137 * @param {!Array<number>|undefined } samples
138138 */
139- function buildHitCountFromSamples ( nodes : ProfileNode [ ] , samples ?: number [ ] ) : void {
139+ function buildHitCountFromSamples ( nodes : ProfileNode [ ] , samples ?: number [ ] ) : void {
140140 /**
141141 * hitCount not defined in ProfileNode model
142142 */
143- if ( typeof ( nodes [ 0 ] . hitCount ) === 'number' ) {
143+ if ( typeof nodes [ 0 ] . hitCount === 'number' ) {
144144 return
145145 }
146146
147- console . assert ( Boolean ( samples ) , 'Error: Neither hitCount nor samples are present in profile.' )
147+ console . assert (
148+ Boolean ( samples ) ,
149+ 'Error: Neither hitCount nor samples are present in profile.'
150+ )
148151 for ( let i = 0 ; i < nodes . length ; ++ i ) {
149152 nodes [ i ] . hitCount = 0
150153 }
@@ -170,7 +173,9 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
170173 const parentNodeStack = root . children . map ( ( ) : CPUProfileNode => resultRoot )
171174
172175 // TODO(Christian) fix typings
173- const sourceNodeStack = root . children . map ( ( id ) : ProfileNode => nodeByIdMap . get ( ( ( id as unknown as number ) ) ) )
176+ const sourceNodeStack = root . children . map (
177+ ( id ) : ProfileNode => nodeByIdMap . get ( id as unknown as number )
178+ )
174179 while ( sourceNodeStack . length ) {
175180 let parentNode = parentNodeStack . pop ( )
176181 const sourceNode = sourceNodeStack . pop ( )
@@ -182,7 +187,10 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
182187 parentNode . children . push ( targetNode )
183188 parentNode = targetNode
184189 idMap . set ( sourceNode . id , parentNode . id )
185- parentNodeStack . push . apply ( parentNodeStack , sourceNode . children . map ( ( ) : CPUProfileNode => parentNode ) )
190+ parentNodeStack . push . apply (
191+ parentNodeStack ,
192+ sourceNode . children . map ( ( ) : CPUProfileNode => parentNode )
193+ )
186194 /**
187195 * type defect
188196 */
@@ -196,7 +204,7 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
196204 return resultRoot
197205 }
198206
199- private _sortSamples ( ) : void {
207+ private _sortSamples ( ) : void {
200208 const timestamps = this . timestamps
201209 if ( ! timestamps ) {
202210 return
@@ -228,7 +236,7 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
228236 }
229237 }
230238
231- private _normalizeTimestamps ( ) : void {
239+ private _normalizeTimestamps ( ) : void {
232240 let timestamps = this . timestamps
233241 if ( ! timestamps ) {
234242 // Support loading old CPU profiles that are missing timestamps.
@@ -257,15 +265,16 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
257265 * Add an extra timestamp used to calculate the last sample duration.
258266 */
259267 if ( this . samples . length === timestamps . length ) {
260- const averageSample = ( timestamps [ timestamps . length - 1 ] - timestamps [ 0 ] ) / ( timestamps . length - 1 )
268+ const averageSample =
269+ ( timestamps [ timestamps . length - 1 ] - timestamps [ 0 ] ) / ( timestamps . length - 1 )
261270 this . timestamps . push ( timestamps [ timestamps . length - 1 ] + averageSample )
262271 }
263272
264273 this . profileStartTime = timestamps [ 0 ]
265274 this . profileEndTime = timestamps [ timestamps . length - 1 ]
266275 }
267276
268- private _buildIdToNodeMap ( ) : void {
277+ private _buildIdToNodeMap ( ) : void {
269278 /** @type {!Map<number, !CPUProfileNode> } */
270279 this . _idToNode = new Map ( )
271280 const idToNode = this . _idToNode
@@ -278,9 +287,13 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
278287 }
279288 }
280289
281- private _extractMetaNodes ( ) : void {
290+ private _extractMetaNodes ( ) : void {
282291 const topLevelNodes = this . profileHead . children
283- for ( let i = 0 ; i < topLevelNodes . length && ! ( this . gcNode && this . programNode && this . idleNode ) ; i ++ ) {
292+ for (
293+ let i = 0 ;
294+ i < topLevelNodes . length && ! ( this . gcNode && this . programNode && this . idleNode ) ;
295+ i ++
296+ ) {
284297 const node = topLevelNodes [ i ]
285298 if ( node . functionName === '(garbage collector)' ) {
286299 this . gcNode = node
@@ -300,7 +313,7 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
300313 * between two call stacks sharing the same bottom node, it is replaced
301314 * with the preceeding sample.
302315 */
303- private _fixMissingSamples ( ) : void {
316+ private _fixMissingSamples ( ) : void {
304317 const samples = this . samples
305318 const samplesCount = samples . length
306319 const idToNode = this . _idToNode
@@ -315,7 +328,7 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
315328 * @param {!SDK.ProfileNode } node
316329 * @return {!SDK.ProfileNode }
317330 */
318- function bottomNode ( node : ProfileNode ) : ProfileNode {
331+ function bottomNode ( node : ProfileNode ) : ProfileNode {
319332 while ( node && node . parent && node . parent . parent ) {
320333 node = node . parent
321334 }
@@ -327,7 +340,7 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
327340 * @param {number } nodeId
328341 * @return {boolean }
329342 */
330- function isSystemNode ( nodeId : number ) : boolean {
343+ function isSystemNode ( nodeId : number ) : boolean {
331344 return nodeId === programNodeId || nodeId === gcNodeId || nodeId === idleNodeId
332345 }
333346
@@ -362,9 +375,15 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
362375 * @param {number= } startTime
363376 * @param {number= } stopTime
364377 */
365- public forEachFrame (
378+ public forEachFrame (
366379 openFrameCallback : ( depth : number , node : CPUProfileNode , startTime : number ) => void ,
367- closeFrameCallback : ( depth : number , node : CPUProfileNode , startTime : number , duration : number , selfTime : number ) => void ,
380+ closeFrameCallback : (
381+ depth : number ,
382+ node : CPUProfileNode ,
383+ startTime : number ,
384+ duration : number ,
385+ selfTime : number
386+ ) => void ,
368387 startTime ?: number ,
369388 stopTime ?: number
370389 ) : void {
@@ -446,6 +465,7 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
446465 )
447466 -- stackTop
448467 prevNode = gcParentNode
468+ // eslint-disable-next-line no-useless-assignment
449469 prevId = prevNode . id
450470 gcParentNode = null
451471 }
@@ -495,7 +515,13 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
495515 const start = stackStartTimes [ stackTop ]
496516 const duration = sampleTime - start
497517 stackChildrenDuration [ stackTop - 1 ] += duration
498- closeFrameCallback ( gcParentNode . depth + 1 , node , start , duration , duration - stackChildrenDuration [ stackTop ] )
518+ closeFrameCallback (
519+ gcParentNode . depth + 1 ,
520+ node ,
521+ start ,
522+ duration ,
523+ duration - stackChildrenDuration [ stackTop ]
524+ )
499525 -- stackTop
500526 prevId = gcParentNode . id
501527 }
@@ -519,7 +545,7 @@ export default class CPUProfileDataModel extends ProfileTreeModel {
519545 * @param {number } index
520546 * @return {?CPUProfileNode }
521547 */
522- public nodeByIndex ( index : number ) : CPUProfileNode {
548+ public nodeByIndex ( index : number ) : CPUProfileNode {
523549 return this . _idToNode . get ( this . samples [ index ] ) || null
524550 }
525551}
0 commit comments