Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(623)

Unified Diff: skia/ext/skia_memory_dump_provider.cc

Issue 1260753004: [tracing] Adding SkGlyphCache detailed statistics to skia dump provider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@skia_v1
Patch Set: Style fixes. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/skia_memory_dump_provider.cc
diff --git a/skia/ext/skia_memory_dump_provider.cc b/skia/ext/skia_memory_dump_provider.cc
index a7c445fd5d4f1f9b34865ac3162a3b7bf0a1688e..da296eac3b1c095c56db509a9cac84c9d8911efb 100644
--- a/skia/ext/skia_memory_dump_provider.cc
+++ b/skia/ext/skia_memory_dump_provider.cc
@@ -4,14 +4,52 @@
#include "skia_memory_dump_provider.h"
+#include "base/strings/stringprintf.h"
#include "base/trace_event/memory_allocator_dump.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/process_memory_dump.h"
+#include "third_party/skia/include/core/SkGlyphCacheStats.h"
#include "third_party/skia/include/core/SkGraphics.h"
#include "third_party/skia/src/core/SkResourceCache.h"
namespace skia {
+namespace {
+
+const char kFontCacheDumpName[] = "skia/sk_font_cache";
+const char kResourceCacheDumpName[] = "skia/sk_resource_cache";
+
+class SkiaGlyphCacheDumper : public SkGlyphCacheStatsDumper {
+ public:
+ SkiaGlyphCacheDumper(
+ base::trace_event::ProcessMemoryDump* process_memory_dump);
+
+ // SkGlyphCacheStatsDumper implementation:
+ void DumpStats(const char* uniqueName, const size_t memoryUsed) override;
+
+ private:
+ base::trace_event::ProcessMemoryDump* process_memory_dump_;
+};
+
+SkiaGlyphCacheDumper::SkiaGlyphCacheDumper(
+ base::trace_event::ProcessMemoryDump* process_memory_dump)
+ : process_memory_dump_(process_memory_dump) {}
+
+void SkiaGlyphCacheDumper::DumpStats(const char* uniqueName,
+ const size_t memoryUsed) {
+ auto cache_mad = process_memory_dump_->CreateAllocatorDump(
+ base::StringPrintf("%s/%s", kFontCacheDumpName, uniqueName));
+
+ cache_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ memoryUsed);
+ cache_mad->AddScalar(
+ base::trace_event::MemoryAllocatorDump::kNameObjectsCount,
+ base::trace_event::MemoryAllocatorDump::kUnitsObjects, 1u);
+}
+
+} // namespace
+
// static
SkiaMemoryDumpProvider* SkiaMemoryDumpProvider::GetInstance() {
return Singleton<SkiaMemoryDumpProvider,
@@ -24,14 +62,21 @@ SkiaMemoryDumpProvider::~SkiaMemoryDumpProvider() {}
bool SkiaMemoryDumpProvider::OnMemoryDump(
base::trace_event::ProcessMemoryDump* process_memory_dump) {
- auto font_mad =
- process_memory_dump->CreateAllocatorDump("skia/sk_font_cache");
- font_mad->AddScalar("size", "bytes", SkGraphics::GetFontCacheUsed());
- font_mad->AddScalar("count", "objects", SkGraphics::GetFontCacheCountUsed());
+ auto font_mad = process_memory_dump->CreateAllocatorDump(kFontCacheDumpName);
+ font_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ SkGraphics::GetFontCacheUsed());
+ font_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectsCount,
+ base::trace_event::MemoryAllocatorDump::kUnitsObjects,
+ SkGraphics::GetFontCacheCountUsed());
+
+ SkiaGlyphCacheDumper dumper(process_memory_dump);
+ DumpSkGlyphCacheStats(&dumper);
auto resource_mad =
- process_memory_dump->CreateAllocatorDump("skia/sk_resource_cache");
- resource_mad->AddScalar("size", "bytes",
+ process_memory_dump->CreateAllocatorDump(kResourceCacheDumpName);
+ resource_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
SkResourceCache::GetTotalBytesUsed());
// TODO(ssid): crbug.com/503168. Add sub-allocation edges from discardable or
// malloc memory dumps to avoid double counting.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698