[Impeller] fixed units for memory measurement (flutter/engine#53687)

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
gaaclarke 2024-07-02 11:32:12 -07:00 committed by GitHub
parent d6cff07930
commit 2f24c4214f
3 changed files with 4 additions and 3 deletions

View File

@ -99,7 +99,8 @@ void DebugAllocatorStats::Decrement(size_t size) {
}
size_t DebugAllocatorStats::GetAllocationSizeMB() {
size_t new_value = size_ / 1000000;
// RAM is measured in MiB, thus a divisor of 2^20 instead of 1,000,000.
size_t new_value = size_ / (1024 * 1024);
return new_value;
}

View File

@ -36,7 +36,7 @@ TEST_P(AllocatorMTLTest, DebugTraceMemoryStatistics) {
TextureDescriptor desc;
desc.format = PixelFormat::kR8G8B8A8UNormInt;
desc.storage_mode = StorageMode::kDeviceTransient;
desc.size = {1000, 1000};
desc.size = {1024, 1024};
auto texture_1 = allocator->CreateTexture(desc);
EXPECT_EQ(allocator->DebugGetHeapUsage(), 0u);

View File

@ -519,7 +519,7 @@ size_t AllocatorVK::DebugGetHeapUsage() const {
total_usage += budget.usage;
}
// Convert bytes to MB.
total_usage *= 1e-6;
total_usage /= (1024 * 1024);
return total_usage;
}