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

Function computeOptimizationStats

deps/v8/tools/profview/profile-utils.js:526–644  ·  view source on GitHub ↗
(file,
    timeStart = -Infinity, timeEnd = Infinity)

Source from the content-addressed store, hash-verified

524}
525
526function computeOptimizationStats(file,
527 timeStart = -Infinity, timeEnd = Infinity) {
528 function newCollection() {
529 return { count : 0, functions : [], functionTable : [] };
530 }
531 function addToCollection(collection, code) {
532 collection.count++;
533 let funcData = collection.functionTable[code.func];
534 if (!funcData) {
535 funcData = { f : file.functions[code.func], instances : [] };
536 collection.functionTable[code.func] = funcData;
537 collection.functions.push(funcData);
538 }
539 funcData.instances.push(code);
540 }
541
542 let functionCount = 0;
543 let baselineFunctionCount = 0;
544 let optimizedFunctionCount = 0;
545 let maglevOptimizedFunctionCount = 0;
546 let deoptimizedFunctionCount = 0;
547 let baselineCompilations = newCollection();
548 let optimizations = newCollection();
549 let maglevOptimizations = newCollection();
550 let eagerDeoptimizations = newCollection();
551 let lazyDeoptimizations = newCollection();
552 let dependencyChangeDeoptimizations = newCollection();
553
554 for (let i = 0; i < file.functions.length; i++) {
555 let f = file.functions[i];
556
557 // Skip special SFIs that do not correspond to JS functions.
558 if (f.codes.length === 0) continue;
559 if (file.code[f.codes[0]].type !== "JS") continue;
560
561 functionCount++;
562 let baselineCompiled = false;
563 let optimized = false;
564 let maglev_optimized = false;
565 let deoptimized = false;
566
567 for (let j = 0; j < f.codes.length; j++) {
568 let code = file.code[f.codes[j]];
569 console.assert(code.type === "JS");
570 if (code.kind === "Sparkplug") {
571 baselineCompiled = true;
572 if (code.tm >= timeStart && code.tm <= timeEnd) {
573 addToCollection(baselineCompilations, code);
574 }
575 }
576 if (code.kind === "Opt") {
577 optimized = true;
578 if (code.tm >= timeStart && code.tm <= timeEnd) {
579 addToCollection(optimizations, code);
580 }
581 }
582 if (code.kind === "Maglev") {
583 maglev_optimized = true;

Callers 1

renderMethod · 0.85

Calls 4

newCollectionFunction · 0.85
addToCollectionFunction · 0.85
sortCollectionFunction · 0.85
assertMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…