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

Unified Diff: Source/platform/fonts/opentype/OpenTypeSanitizer.cpp

Issue 842913004: UMA histogram to measure the time OTS takes to decode a webfont (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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: Source/platform/fonts/opentype/OpenTypeSanitizer.cpp
diff --git a/Source/platform/fonts/opentype/OpenTypeSanitizer.cpp b/Source/platform/fonts/opentype/OpenTypeSanitizer.cpp
index d17f9f9b3adb0e7bc8134749a64ebaaca4a651db..90500b7cac1ebde94f3b7731b1e4c97c73d33621 100644
--- a/Source/platform/fonts/opentype/OpenTypeSanitizer.cpp
+++ b/Source/platform/fonts/opentype/OpenTypeSanitizer.cpp
@@ -31,12 +31,32 @@
#include "config.h"
#include "platform/fonts/opentype/OpenTypeSanitizer.h"
-#include "platform/SharedBuffer.h"
#include "opentype-sanitiser.h"
#include "ots-memory-stream.h"
+#include "platform/SharedBuffer.h"
+#include "public/platform/Platform.h"
+#include "wtf/CurrentTime.h"
namespace blink {
+static void recordDecodeSpeedHistogram(SharedBuffer* buffer, double decodeTime, size_t decodedSize)
+{
+ if (decodeTime <= 0)
+ return;
+
+ const char* histogramName = "WebFont.DecodeSpeed.SFNT";
+ if (buffer->size() >= 4) {
+ const char* data = buffer->data();
+ if (data[0] == 'w' && data[1] == 'O' && data[2] == 'F' && data[3] == 'F')
+ histogramName = "WebFont.DecodeSpeed.WOFF";
+ else if (data[0] == 'w' && data[1] == 'O' && data[2] == 'F' && data[3] == '2')
+ histogramName = "WebFont.DecodeSpeed.WOFF2";
+ }
+
+ double kbPerSecond = decodedSize / (1000 * decodeTime);
+ blink::Platform::current()->histogramCustomCounts(histogramName, kbPerSecond, 0, 500000, 50);
+}
+
PassRefPtr<SharedBuffer> OpenTypeSanitizer::sanitize()
{
if (!m_buffer)
@@ -57,10 +77,12 @@ PassRefPtr<SharedBuffer> OpenTypeSanitizer::sanitize()
// much larger than the original.
ots::ExpandingMemoryStream output(m_buffer->size(), maxWebFontSize);
+ double start = currentTime();
if (!ots::Process(&output, reinterpret_cast<const uint8_t*>(m_buffer->data()), m_buffer->size()))
return nullptr;
const size_t transcodeLen = output.Tell();
+ recordDecodeSpeedHistogram(m_buffer, currentTime() - start, transcodeLen);
return SharedBuffer::create(static_cast<unsigned char*>(output.get()), transcodeLen);
}
« 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