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

Side by Side Diff: third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp

Issue 2289303004: WebFonts: measure network loading time (Closed)
Patch Set: use histogram_suffixes Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/RemoteFontFaceSource.h" 5 #include "core/css/RemoteFontFaceSource.h"
6 6
7 #include "core/css/CSSCustomFontData.h" 7 #include "core/css/CSSCustomFontData.h"
8 #include "core/css/CSSFontFace.h" 8 #include "core/css/CSSFontFace.h"
9 #include "core/css/CSSFontSelector.h" 9 #include "core/css/CSSFontSelector.h"
10 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 return; 256 return;
257 int duration = static_cast<int>(currentTimeMS() - m_blankPaintTime); 257 int duration = static_cast<int>(currentTimeMS() - m_blankPaintTime);
258 DEFINE_STATIC_LOCAL(CustomCountHistogram, blankTextShownTimeHistogram, ("Web Font.BlankTextShownTime", 0, 10000, 50)); 258 DEFINE_STATIC_LOCAL(CustomCountHistogram, blankTextShownTimeHistogram, ("Web Font.BlankTextShownTime", 0, 10000, 50));
259 blankTextShownTimeHistogram.count(duration); 259 blankTextShownTimeHistogram.count(duration);
260 m_blankPaintTime = -1; 260 m_blankPaintTime = -1;
261 } 261 }
262 262
263 void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont(const FontResour ce* font, bool isLoadedFromMemoryCache) 263 void RemoteFontFaceSource::FontLoadHistograms::recordRemoteFont(const FontResour ce* font, bool isLoadedFromMemoryCache)
264 { 264 {
265 if (m_loadStartTime > 0 && font && !font->isLoading()) { 265 if (m_loadStartTime > 0 && font && !font->isLoading()) {
266 int duration = static_cast<int>(currentTimeMS() - m_loadStartTime);
267 recordLoadTimeHistogram(font, duration);
268 m_loadStartTime = -1;
269
270 enum { Miss, DiskHit, DataUrl, MemoryHit, CacheHitEnumMax }; 266 enum { Miss, DiskHit, DataUrl, MemoryHit, CacheHitEnumMax };
271 int histogramValue = font->url().protocolIsData() ? DataUrl 267 int cacheHitValue = font->url().protocolIsData() ? DataUrl
272 : isLoadedFromMemoryCache ? MemoryHit 268 : isLoadedFromMemoryCache ? MemoryHit
273 : font->response().wasCached() ? DiskHit 269 : font->response().wasCached() ? DiskHit
274 : Miss; 270 : Miss;
275 DEFINE_STATIC_LOCAL(EnumerationHistogram, cacheHitHistogram, ("WebFont.C acheHit", CacheHitEnumMax)); 271 DEFINE_STATIC_LOCAL(EnumerationHistogram, cacheHitHistogram, ("WebFont.C acheHit", CacheHitEnumMax));
276 cacheHitHistogram.count(histogramValue); 272 cacheHitHistogram.count(cacheHitValue);
273
274 int duration = static_cast<int>(currentTimeMS() - m_loadStartTime);
275 recordLoadTimeHistogram(font, duration, cacheHitValue == Miss);
276 m_loadStartTime = -1;
277 277
278 enum { CORSFail, CORSSuccess, CORSEnumMax }; 278 enum { CORSFail, CORSSuccess, CORSEnumMax };
279 int corsValue = font->isCORSFailed() ? CORSFail : CORSSuccess; 279 int corsValue = font->isCORSFailed() ? CORSFail : CORSSuccess;
280 DEFINE_STATIC_LOCAL(EnumerationHistogram, corsHistogram, ("WebFont.CORSS uccess", CORSEnumMax)); 280 DEFINE_STATIC_LOCAL(EnumerationHistogram, corsHistogram, ("WebFont.CORSS uccess", CORSEnumMax));
281 corsHistogram.count(corsValue); 281 corsHistogram.count(corsValue);
282 } 282 }
283 } 283 }
284 284
285 void RemoteFontFaceSource::FontLoadHistograms::recordLoadTimeHistogram(const Fon tResource* font, int duration) 285 void RemoteFontFaceSource::FontLoadHistograms::recordLoadTimeHistogram(const Fon tResource* font, int duration, bool isLoadedFromNetwork)
286 { 286 {
287 if (font->errorOccurred()) { 287 if (font->errorOccurred()) {
288 DEFINE_STATIC_LOCAL(CustomCountHistogram, loadErrorHistogram, ("WebFont. DownloadTime.LoadError", 0, 10000, 50)); 288 DEFINE_STATIC_LOCAL(CustomCountHistogram, loadErrorHistogram, ("WebFont. DownloadTime.LoadError", 0, 10000, 50));
289 DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheLoadErrorHistogram, ("WebFont.MissedCache.DownloadTime.LoadError", 0, 10000, 50));
289 loadErrorHistogram.count(duration); 290 loadErrorHistogram.count(duration);
291 if (isLoadedFromNetwork)
292 missedCacheLoadErrorHistogram.count(duration);
290 return; 293 return;
291 } 294 }
292 295
293 unsigned size = font->encodedSize(); 296 unsigned size = font->encodedSize();
294 if (size < 10 * 1024) { 297 if (size < 10 * 1024) {
295 DEFINE_STATIC_LOCAL(CustomCountHistogram, under10kHistogram, ("WebFont.D ownloadTime.0.Under10KB", 0, 10000, 50)); 298 DEFINE_STATIC_LOCAL(CustomCountHistogram, under10kHistogram, ("WebFont.D ownloadTime.0.Under10KB", 0, 10000, 50));
299 DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheUnder10kHistogram, ("WebFont.MissedCache.DownloadTime.0.Under10KB", 0, 10000, 50));
296 under10kHistogram.count(duration); 300 under10kHistogram.count(duration);
301 if (isLoadedFromNetwork)
302 missedCacheUnder10kHistogram.count(duration);
297 return; 303 return;
298 } 304 }
299 if (size < 50 * 1024) { 305 if (size < 50 * 1024) {
300 DEFINE_STATIC_LOCAL(CustomCountHistogram, under50kHistogram, ("WebFont.D ownloadTime.1.10KBTo50KB", 0, 10000, 50)); 306 DEFINE_STATIC_LOCAL(CustomCountHistogram, under50kHistogram, ("WebFont.D ownloadTime.1.10KBTo50KB", 0, 10000, 50));
307 DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheUnder50kHistogram, ("WebFont.MissedCache.DownloadTime.1.10KBTo50KB", 0, 10000, 50));
301 under50kHistogram.count(duration); 308 under50kHistogram.count(duration);
309 if (isLoadedFromNetwork)
310 missedCacheUnder50kHistogram.count(duration);
302 return; 311 return;
303 } 312 }
304 if (size < 100 * 1024) { 313 if (size < 100 * 1024) {
305 DEFINE_STATIC_LOCAL(CustomCountHistogram, under100kHistogram, ("WebFont. DownloadTime.2.50KBTo100KB", 0, 10000, 50)); 314 DEFINE_STATIC_LOCAL(CustomCountHistogram, under100kHistogram, ("WebFont. DownloadTime.2.50KBTo100KB", 0, 10000, 50));
315 DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheUnder100kHistogram, ("WebFont.MissedCache.DownloadTime.2.50KBTo100KB", 0, 10000, 50));
306 under100kHistogram.count(duration); 316 under100kHistogram.count(duration);
317 if (isLoadedFromNetwork)
318 missedCacheUnder100kHistogram.count(duration);
307 return; 319 return;
308 } 320 }
309 if (size < 1024 * 1024) { 321 if (size < 1024 * 1024) {
310 DEFINE_STATIC_LOCAL(CustomCountHistogram, under1mbHistogram, ("WebFont.D ownloadTime.3.100KBTo1MB", 0, 10000, 50)); 322 DEFINE_STATIC_LOCAL(CustomCountHistogram, under1mbHistogram, ("WebFont.D ownloadTime.3.100KBTo1MB", 0, 10000, 50));
323 DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheUnder1mbHistogram, ("WebFont.MissedCache.DownloadTime.3.100KBTo1MB", 0, 10000, 50));
311 under1mbHistogram.count(duration); 324 under1mbHistogram.count(duration);
325 if (isLoadedFromNetwork)
326 missedCacheUnder1mbHistogram.count(duration);
312 return; 327 return;
313 } 328 }
314 DEFINE_STATIC_LOCAL(CustomCountHistogram, over1mbHistogram, ("WebFont.Downlo adTime.4.Over1MB", 0, 10000, 50)); 329 DEFINE_STATIC_LOCAL(CustomCountHistogram, over1mbHistogram, ("WebFont.Downlo adTime.4.Over1MB", 0, 10000, 50));
330 DEFINE_STATIC_LOCAL(CustomCountHistogram, missedCacheOver1mbHistogram, ("Web Font.MissedCache.DownloadTime.4.Over1MB", 0, 10000, 50));
315 over1mbHistogram.count(duration); 331 over1mbHistogram.count(duration);
332 if (isLoadedFromNetwork)
333 missedCacheOver1mbHistogram.count(duration);
316 } 334 }
317 335
318 void RemoteFontFaceSource::FontLoadHistograms::recordInterventionResult(bool isT riggered, bool isLoadedFromNetwork) 336 void RemoteFontFaceSource::FontLoadHistograms::recordInterventionResult(bool isT riggered, bool isLoadedFromNetwork)
319 { 337 {
320 // interventionResult takes 0-3 values. 338 // interventionResult takes 0-3 values.
321 int interventionResult = 0; 339 int interventionResult = 0;
322 if (m_isLongLimitExceeded) 340 if (m_isLongLimitExceeded)
323 interventionResult |= 1 << 0; 341 interventionResult |= 1 << 0;
324 if (isTriggered) 342 if (isTriggered)
325 interventionResult |= 1 << 1; 343 interventionResult |= 1 << 1;
326 const int boundary = 1 << 2; 344 const int boundary = 1 << 2;
327 345
328 DEFINE_STATIC_LOCAL(EnumerationHistogram, interventionHistogram, ("WebFont.I nterventionResult", boundary)); 346 DEFINE_STATIC_LOCAL(EnumerationHistogram, interventionHistogram, ("WebFont.I nterventionResult", boundary));
329 DEFINE_STATIC_LOCAL(EnumerationHistogram, missedCacheInterventionHistogram, ("WebFont.InterventionResult.MissedCache", boundary)); 347 DEFINE_STATIC_LOCAL(EnumerationHistogram, missedCacheInterventionHistogram, ("WebFont.InterventionResult.MissedCache", boundary));
330 interventionHistogram.count(interventionResult); 348 interventionHistogram.count(interventionResult);
331 if (isLoadedFromNetwork) 349 if (isLoadedFromNetwork)
332 missedCacheInterventionHistogram.count(interventionResult); 350 missedCacheInterventionHistogram.count(interventionResult);
333 } 351 }
334 352
335 } // namespace blink 353 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698