[flutter_driver] add allocator mtl to memory event allowlist. (#151153)

Flutter driver side changes for https://github.com/flutter/engine/pull/53618
This commit is contained in:
Jonah Williams 2024-07-02 08:34:04 -07:00 committed by GitHub
parent a052fb7638
commit 61326afdae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View File

@ -21,7 +21,7 @@ class GPUMemorySumarizer {
}
/// Whether or not this event is a GPU allocation event.
static const Set<String> kMemoryEvents = <String>{'AllocatorVK'};
static const Set<String> kMemoryEvents = <String>{'AllocatorVK', 'AllocatorMTL'};
final List<double> _memoryMB = <double>[];

View File

@ -15,6 +15,14 @@ TimelineEvent newGPUTraceEvent(double ms) => TimelineEvent(<String, dynamic>{
},
});
TimelineEvent newMetalGPUTraceEvent(double ms) => TimelineEvent(<String, dynamic>{
'name': 'AllocatorMTL',
'ph': 'b',
'args': <String, String>{
'MemoryBudgetUsageMB': ms.toString()
},
});
void main() {
test('Can process GPU memory usage times.', () {
final GPUMemorySumarizer summarizer = GPUMemorySumarizer(<TimelineEvent>[
@ -28,4 +36,17 @@ void main() {
expect(summarizer.computePercentileMemoryUsage(50.0), closeTo(1024, 0.1));
expect(summarizer.computeWorstMemoryUsage(), 2048);
});
test('Can process Metal GPU memory usage times.', () {
final GPUMemorySumarizer summarizer = GPUMemorySumarizer(<TimelineEvent>[
newMetalGPUTraceEvent(1024),
newMetalGPUTraceEvent(1024),
newMetalGPUTraceEvent(512),
newMetalGPUTraceEvent(2048),
]);
expect(summarizer.computeAverageMemoryUsage(), closeTo(1152, 0.1));
expect(summarizer.computePercentileMemoryUsage(50.0), closeTo(1024, 0.1));
expect(summarizer.computeWorstMemoryUsage(), 2048);
});
}