Skip to content

Commit ea58965

Browse files
authored
Add metric for HeapTotal and Resident Set size (#147)
* Add metric for HeapTotal and Resident Set size * Add External and ArrayBuffers metric too
1 parent 8819275 commit ea58965

File tree

1 file changed

+84
-0
lines changed
  • packages/vscode-js-profile-flame/src/realtime

1 file changed

+84
-0
lines changed

packages/vscode-js-profile-flame/src/realtime/metrics.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,86 @@ export class HeapMetric extends Metric {
104104
}
105105
}
106106

107+
export class HeapTotalMetric extends Metric {
108+
public update(timestamp: number, metrics: IDAMetrics): void {
109+
if (metrics.memory /* node */) {
110+
this.push(timestamp, metrics.memory.heapTotal);
111+
}
112+
}
113+
114+
public format(metric: number): string {
115+
return formatSize(metric);
116+
}
117+
118+
public short(): string {
119+
return 'Heap Total';
120+
}
121+
122+
public name(): string {
123+
return 'Heap Total';
124+
}
125+
}
126+
127+
export class ResidentSetMetric extends Metric {
128+
public update(timestamp: number, metrics: IDAMetrics): void {
129+
if (metrics.memory /* node */) {
130+
this.push(timestamp, metrics.memory.rss);
131+
}
132+
}
133+
134+
public format(metric: number): string {
135+
return formatSize(metric);
136+
}
137+
138+
public short(): string {
139+
return 'RSS';
140+
}
141+
142+
public name(): string {
143+
return 'Resident Set Size';
144+
}
145+
}
146+
147+
export class ExternalMetric extends Metric {
148+
public update(timestamp: number, metrics: IDAMetrics): void {
149+
if (metrics.memory /* node */) {
150+
this.push(timestamp, metrics.memory.external);
151+
}
152+
}
153+
154+
public format(metric: number): string {
155+
return formatSize(metric);
156+
}
157+
158+
public short(): string {
159+
return 'External';
160+
}
161+
162+
public name(): string {
163+
return 'External Memory';
164+
}
165+
}
166+
167+
export class ArrayBuffersMetric extends Metric {
168+
public update(timestamp: number, metrics: IDAMetrics): void {
169+
if (metrics.memory /* node */) {
170+
this.push(timestamp, metrics.memory.arrayBuffers);
171+
}
172+
}
173+
174+
public format(metric: number): string {
175+
return formatSize(metric);
176+
}
177+
178+
public short(): string {
179+
return 'ArrayBuffer';
180+
}
181+
182+
public name(): string {
183+
return 'ArrayBuffer Memory';
184+
}
185+
}
186+
107187
export class DOMNodes extends Metric {
108188
public update(timestamp: number, metrics: IDAMetrics): void {
109189
if (metrics.Nodes) {
@@ -167,6 +247,10 @@ export class StyleRecalcs extends DerivativeMetric {
167247
export const createMetrics = () => [
168248
new CpuMetric(),
169249
new HeapMetric(),
250+
new HeapTotalMetric(),
251+
new ResidentSetMetric(),
252+
new ExternalMetric(),
253+
new ArrayBuffersMetric(),
170254
new DOMNodes(),
171255
new LayoutCount(),
172256
new StyleRecalcs(),

0 commit comments

Comments
 (0)