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

Method calculateMetrics

deps/v8/tools/parse-processor.mjs:327–394  ·  view source on GitHub ↗
(printSummary)

Source from the content-addressed store, hash-verified

325 }
326
327 calculateMetrics(printSummary) {
328 let log = (str) => this.summary += str + '\n';
329 log(`SCRIPT: ${this.id}`);
330 let all = this.funktions;
331 if (all.length === 0) return;
332
333 let nofFunktions = all.length;
334 let ownBytesSum = list => {
335 return list.reduce((bytes, each) => bytes + each.getOwnBytes(), 0)
336 };
337
338 let info = (name, funktions) => {
339 let ownBytes = ownBytesSum(funktions);
340 let nofPercent = Math.round(funktions.length / nofFunktions * 100);
341 let value = (funktions.length + "#").padStart(7) +
342 (nofPercent + "%").padStart(5) +
343 BYTES(ownBytes, this.bytesTotal).padStart(16);
344 log((` - ${name}`).padEnd(20) + value);
345 this.metrics.set(name + "-bytes", ownBytes);
346 this.metrics.set(name + "-count", funktions.length);
347 this.metrics.set(name + "-count-percent", nofPercent);
348 this.metrics.set(name + "-bytes-percent",
349 Math.round(ownBytes / this.bytesTotal * 100));
350 };
351
352 log(` - file: ${this.file}`);
353 log(' - details: ' +
354 'isEval=' + this.isEval + ' deserialized=' + this.isDeserialized +
355 ' streamed=' + this.isStreamingCompiled);
356 log(" Category Count Bytes");
357 info("scripts", this.getScripts());
358 info("functions", all);
359 info("toplevel fns", all.filter(each => each.isToplevel()));
360 info('preparsed', all.filter(each => each.preparseDuration > 0));
361
362 info('fully parsed', all.filter(each => each.parseDuration > 0));
363 // info("fn parsed", all.filter(each => each.parse2Duration > 0));
364 // info("resolved", all.filter(each => each.resolutionDuration > 0));
365 info("executed", all.filter(each => each.executionTimestamp > 0));
366 info('eval', all.filter(each => each.isEval));
367 info("lazy compiled", all.filter(each => each.lazyCompileTimestamp > 0));
368 info("eager compiled", all.filter(each => each.compileTimestamp > 0));
369
370 info("baseline", all.filter(each => each.baselineTimestamp > 0));
371 info("optimized", all.filter(each => each.optimizeTimestamp > 0));
372
373 log(" Cost split: executed vs non-executed functions, max = longest single event");
374 const costs = [
375 ['parse', each => each.parseDuration],
376 ['preparse', each => each.preparseDuration],
377 ['resolution', each => each.resolutionDuration],
378 ['compile-eager', each => each.compileDuration],
379 ['compile-lazy', each => each.lazyCompileDuration],
380 ['baseline', each => each.baselineDuration],
381 ['optimize', each => each.optimizeDuration],
382 ];
383 for (let [name, fn] of costs) {
384 const executionCost = new ExecutionCost(name, all, fn);

Callers 1

postProcessMethod · 0.80

Calls 10

getScriptsMethod · 0.95
setMetricsMethod · 0.95
toStringMethod · 0.95
setMetricsMethod · 0.95
toStringMethod · 0.95
isToplevelMethod · 0.80
filterMethod · 0.65
logFunction · 0.50
infoFunction · 0.50
logMethod · 0.45

Tested by

no test coverage detected