@yuebai008/cli
Version:
Command line interface for rapid qg-minigame development
1 lines • 1.17 kB
JavaScript
export class ProfileNode{callFrame;callUID;self;total;id;parent;children;functionName;depth;deoptReason;constructor(t){this.callFrame=t,this.callUID=`${t.functionName}@${t.scriptId}:${t.lineNumber}:${t.columnNumber}`,this.self=0,this.total=0,this.id=0,this.functionName=t.functionName,this.parent=null,this.children=[]}get scriptId(){return String(this.callFrame.scriptId)}get url(){return this.callFrame.url}get lineNumber(){return this.callFrame.lineNumber}get columnNumber(){return this.callFrame.columnNumber}setFunctionName(t){null!==t&&(this.functionName=t)}}export class ProfileTreeModel{root;total;maxDepth;constructor(){}initialize(t){this.root=t,this.assignDepthsAndParents(),this.total=this.calculateTotals(this.root)}assignDepthsAndParents(){const t=this.root;t.depth=-1,t.parent=null,this.maxDepth=0;const e=[t];for(;e.length;){const t=e.pop(),l=t.depth+1;l>this.maxDepth&&(this.maxDepth=l);const n=t.children;for(const r of n)r.depth=l,r.parent=t,e.push(r)}}calculateTotals(t){const e=[t],l=[];for(;e.length;){const t=e.pop();t.total=t.self,l.push(t),e.push(...t.children)}for(;l.length>1;){const t=l.pop();t.parent&&(t.parent.total+=t.total)}return t.total}}