MCPcopy Create free account
hub / github.com/angular/angular / take

Method take

packages/compiler-cli/preprocessor/src/perf.ts:477–544  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

475 }
476
477 take(): {events: TraceEvent[]; summary: PerfSummary} {
478 const now = nowMicros();
479 const summary = emptySummary(Math.round(now - this.startUs));
480 const node = summary.node;
481 for (let kind = 0; kind < SPAN_KINDS; kind++) {
482 if (this.spanCount[kind] > 0) {
483 node.spans[SpanKind[kind]] = {
484 count: this.spanCount[kind],
485 selfUs: Math.round(this.spanSelfUs[kind]),
486 inclusiveUs: Math.round(this.spanInclusiveUs[kind]),
487 };
488 }
489 if (this.asyncCount[kind] > 0) {
490 node.async[SpanKind[kind]] = {
491 count: this.asyncCount[kind],
492 wallUs: Math.round(this.asyncWallUs[kind]),
493 };
494 }
495 }
496 node.mainThreadBusyUs = Math.round(this.busyUs);
497 for (let counter = 0; counter < COUNTERS; counter++) {
498 node.counters[Counter[counter]] = this.counters[counter];
499 }
500 if (this.gcObserver !== undefined) {
501 // Entries are delivered a tick after the GC, so ones from the last tick may be missed.
502 // `takeRecords` is missing from some @types/node versions.
503 const observer = this.gcObserver as unknown as {takeRecords?(): PerformanceEntry[]};
504 this.addGcEntries(observer.takeRecords?.() ?? []);
505 this.gcObserver.disconnect();
506 this.gcObserver = undefined;
507 }
508 node.gc = {count: this.gcCount, totalUs: Math.round(this.gcUs)};
509 const {spans, async, ...nodeTotals} = node;
510 if (this.rust !== undefined) {
511 summary.rust = this.rust;
512 }
513
514 const pid = this.pid;
515 const events: TraceEvent[] = [
516 metadata('process_name', pid, 0, 'ngp'),
517 metadata('thread_name', pid, 1, 'main'),
518 metadata('thread_name', pid, GC_TID, 'gc'),
519 ...this.events,
520 {name: 'ngp.Counters', cat: 'ngp', ph: 'C', pid, tid: 1, ts: now, args: {...node.counters}},
521 // Spans are left out; the timeline has them.
522 {name: 'ngp.Summary', cat: 'ngp', ph: 'i', s: 'p', pid, tid: 1, ts: now, args: nodeTotals},
523 ];
524
525 // A section still open (a `sliceAsync` whose promise hasn't settled) is dropped.
526 this.openKind.length = 0;
527 this.openStart.length = 0;
528 this.openFile.length = 0;
529 this.openChildUs.length = 0;
530 this.openNonAwaiting = 0;
531 this.events = [];
532 this.spanCount.fill(0);
533 this.spanInclusiveUs.fill(0);
534 this.spanSelfUs.fill(0);

Callers

nothing calls this directly

Calls 6

addGcEntriesMethod · 0.95
nowMicrosFunction · 0.85
emptySummaryFunction · 0.85
metadataFunction · 0.70
disconnectMethod · 0.65
takeRecordsMethod · 0.45

Tested by

no test coverage detected