MCPcopy Index your code
hub / github.com/nodejs/node / getFlatProfile

Method getFlatProfile

deps/v8/tools/profile.mjs:793–839  ·  view source on GitHub ↗

* Calculates a flat profile of callees starting from a node with * the specified label. If no name specified, starts from the root. * * @param {string} opt_label Starting node label.

(opt_label)

Source from the content-addressed store, hash-verified

791 * @param {string} opt_label Starting node label.
792 */
793 getFlatProfile(opt_label) {
794 const counters = new CallTree();
795 const rootLabel = opt_label || CallTree.ROOT_NODE_LABEL;
796 const precs = {__proto__:null};
797 precs[rootLabel] = 0;
798 const root = counters.findOrAddChild(rootLabel);
799
800 this.topDownTree_.computeTotalWeights();
801 this.topDownTree_.traverseInDepth(
802 function onEnter(node) {
803 if (!(node.label in precs)) {
804 precs[node.label] = 0;
805 }
806 const nodeLabelIsRootLabel = node.label == rootLabel;
807 if (nodeLabelIsRootLabel || precs[rootLabel] > 0) {
808 if (precs[rootLabel] == 0) {
809 root.selfWeight += node.selfWeight;
810 root.totalWeight += node.totalWeight;
811 } else {
812 const rec = root.findOrAddChild(node.label);
813 rec.selfWeight += node.selfWeight;
814 if (nodeLabelIsRootLabel || precs[node.label] == 0) {
815 rec.totalWeight += node.totalWeight;
816 }
817 }
818 precs[node.label]++;
819 }
820 },
821 function onExit(node) {
822 if (node.label == rootLabel || precs[rootLabel] > 0) {
823 precs[node.label]--;
824 }
825 },
826 null);
827
828 if (!opt_label) {
829 // If we have created a flat profile for the whole program, we don't
830 // need an explicit root in it. Thus, replace the counters tree
831 // root with the node corresponding to the whole program.
832 counters.root_ = root;
833 } else {
834 // Propagate weights so percents can be calculated correctly.
835 counters.getRoot().selfWeight = root.selfWeight;
836 counters.getRoot().totalWeight = root.totalWeight;
837 }
838 return counters;
839 }
840
841 getCEntryProfile() {
842 const result = [new CEntryNode("TOTAL", 0)];

Callers 2

printStatisticsMethod · 0.80
profile.mjsFile · 0.80

Calls 4

findOrAddChildMethod · 0.95
getRootMethod · 0.95
computeTotalWeightsMethod · 0.80
traverseInDepthMethod · 0.80

Tested by

no test coverage detected