memoryProfileSummary()

in frontend/app/components/memory_profile/memory_profile_summary/memory_profile_summary.ts [29:80]


  memoryProfileSummary() {
    if (!this.data || !this.data.memoryIds || !this.data.memoryIds.length ||
        !this.data.memoryProfilePerAllocator) {
      return;
    }

    const summary =
        this.data.memoryProfilePerAllocator[this.memoryId].profileSummary;
    const snapshots = this.data.memoryProfilePerAllocator[this.memoryId]
                          .memoryProfileSnapshots;
    if (!summary || !snapshots) {
      return;
    }

    const peakStats = summary.peakStats;
    if (!peakStats) {
      return;
    }

    let numAllocations = 0;
    let numDeallocations = 0;
    for (let i = 0; i < snapshots.length; i++) {
      const snapshot = snapshots[i];
      if (!snapshot || !snapshot.activityMetadata ||
          !snapshot.activityMetadata.memoryActivity) {
        return;
      }
      if (snapshot.activityMetadata.memoryActivity === 'ALLOCATION') {
        numAllocations++;
      } else if (snapshot.activityMetadata.memoryActivity === 'DEALLOCATION') {
        numDeallocations++;
      }
    }

    this.numAllocations = numAllocations;
    this.numDeallocations = numDeallocations;
    this.memoryCapacity =
        humanReadableText(Number(summary.memoryCapacity) || 0);
    this.peakHeapUsageLifetime =
        humanReadableText(Number(summary.peakBytesUsageLifetime) || 0);
    this.timestampAtPeakMs =
        this.picoToMilli(summary.peakStatsTimePs).toFixed(1);
    this.peakMemUsageProfile =
        humanReadableText(Number(peakStats.peakBytesInUse) || 0);
    this.stackAtPeak =
        humanReadableText(Number(peakStats.stackReservedBytes) || 0);
    this.heapAtPeak =
        humanReadableText(Number(peakStats.heapAllocatedBytes) || 0);
    this.freeAtPeak = humanReadableText(Number(peakStats.freeMemoryBytes) || 0);
    this.fragmentationAtPeakPct =
        ((peakStats.fragmentation || 0) * 100).toFixed(2) + '%';
  }