Bug 707959. Add word cache and font cache telemetry probes. r=roc

This commit is contained in:
John Daggett 2012-02-15 15:37:48 +09:00
parent a34a09dbd7
commit ad926a3cef
3 changed files with 22 additions and 0 deletions

View File

@ -70,6 +70,9 @@
#include "prinit.h"
#include "mozilla/Preferences.h"
#include "mozilla/Telemetry.h"
using namespace mozilla;
static PRLogModuleInfo *gFontLog = PR_NewLogModule("ft2fonts");
@ -614,6 +617,7 @@ gfxFT2Font::GetOrMakeFont(FT2FontEntry *aFontEntry, const gfxFontStyle *aStyle,
bool aNeedsBold)
{
nsRefPtr<gfxFont> font = gfxFontCache::GetCache()->Lookup(aFontEntry, aStyle);
Telemetry::Accumulate(Telemetry::FONT_CACHE_HIT, font != nsnull);
if (!font) {
cairo_scaled_font_t *scaledFont = aFontEntry->CreateScaledFont(aStyle);
font = new gfxFT2Font(scaledFont, aFontEntry, aStyle, aNeedsBold);

View File

@ -70,6 +70,7 @@
#include "nsStyleConsts.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/Telemetry.h"
#include "cairo.h"
#include "gfxFontTest.h"
@ -204,6 +205,7 @@ gfxFontEntry::FindOrMakeFont(const gfxFontStyle *aStyle, bool aNeedsBold)
// the font entry name is the psname, not the family name
nsRefPtr<gfxFont> font = gfxFontCache::GetCache()->Lookup(this, aStyle);
Telemetry::Accumulate(Telemetry::FONT_CACHE_HIT, font != nsnull);
if (!font) {
gfxFont *newFont = CreateFontInstance(aStyle, aNeedsBold);
if (!newFont)
@ -1920,8 +1922,13 @@ gfxFont::GetShapedWord(gfxContext *aContext,
CacheHashEntry *entry = mWordCache.PutEntry(key);
gfxShapedWord *sw = entry->mShapedWord;
Telemetry::Accumulate(Telemetry::WORD_CACHE_LOOKUP_LEN, aLength);
Telemetry::Accumulate(Telemetry::WORD_CACHE_LOOKUP_SCRIPT, aRunScript);
if (sw) {
sw->ResetAge();
Telemetry::Accumulate(Telemetry::WORD_CACHE_HIT_LEN, aLength);
Telemetry::Accumulate(Telemetry::WORD_CACHE_HIT_SCRIPT, aRunScript);
return sw;
}

View File

@ -128,6 +128,17 @@ HISTOGRAM(MAC_INITFONTLIST_TOTAL, 1, 30000, 10, EXPONENTIAL, "gfxMacPlatformFont
HISTOGRAM(SYSTEM_FONT_FALLBACK, 1, 100000, 50, EXPONENTIAL, "System font fallback (us)")
HISTOGRAM(SYSTEM_FONT_FALLBACK_FIRST, 1, 40000, 20, EXPONENTIAL, "System font fallback, first call (ms)")
/**
* Word cache - one count for overall lookups, the other for the number of times a word is found
* Note: range and number of buckets must match
*/
HISTOGRAM(WORD_CACHE_LOOKUP_LEN, 1, 256, 30, EXPONENTIAL, "Word cache lookup (chars)")
HISTOGRAM(WORD_CACHE_HIT_LEN, 1, 256, 30, EXPONENTIAL, "Word cache hit (chars)")
HISTOGRAM(WORD_CACHE_LOOKUP_SCRIPT, 1, 110, 111, LINEAR, "Word cache lookup (script)")
HISTOGRAM(WORD_CACHE_HIT_SCRIPT, 1, 110, 111, LINEAR, "Word cache hit (script)")
HISTOGRAM_BOOLEAN(FONT_CACHE_HIT, "font cache hit")
HISTOGRAM_BOOLEAN(SHUTDOWN_OK, "Did the browser start after a successful shutdown")
HISTOGRAM(IMAGE_DECODE_LATENCY, 50, 5000000, 100, EXPONENTIAL, "Time spent decoding an image chunk (us)")