Bug 673176. Record decoding speed for different image decoders. r=jlebar

--HG--
extra : transplant_source : %1A%1Dav%7C%C5%BF%9B%09%94bl%AC%14%CCpg%24R%AE
This commit is contained in:
Jeff Muizelaar 2011-09-22 16:25:56 -04:00
parent df43a60f91
commit ed391c7c80
10 changed files with 36 additions and 0 deletions

View File

@ -1096,5 +1096,12 @@ done:
return;
}
Telemetry::ID
nsGIFDecoder2::SpeedHistogram()
{
return Telemetry::IMAGE_DECODE_SPEED_GIF;
}
} // namespace imagelib
} // namespace mozilla

View File

@ -63,6 +63,7 @@ public:
virtual void WriteInternal(const char* aBuffer, PRUint32 aCount);
virtual void FinishInternal();
virtual Telemetry::ID SpeedHistogram();
private:
/* These functions will be called when the decoder has a decoded row,

View File

@ -153,6 +153,11 @@ nsJPEGDecoder::~nsJPEGDecoder()
this));
}
Telemetry::ID
nsJPEGDecoder::SpeedHistogram()
{
return Telemetry::IMAGE_DECODE_SPEED_JPEG;
}
void
nsJPEGDecoder::InitInternal()

View File

@ -93,6 +93,7 @@ public:
virtual void WriteInternal(const char* aBuffer, PRUint32 aCount);
virtual void FinishInternal();
virtual Telemetry::ID SpeedHistogram();
void NotifyDone();
protected:

View File

@ -879,5 +879,12 @@ nsPNGDecoder::warning_callback(png_structp png_ptr, png_const_charp warning_msg)
PR_LOG(gPNGLog, PR_LOG_WARNING, ("libpng warning: %s\n", warning_msg));
}
Telemetry::ID
nsPNGDecoder::SpeedHistogram()
{
return Telemetry::IMAGE_DECODE_SPEED_PNG;
}
} // namespace imagelib
} // namespace mozilla

View File

@ -64,6 +64,7 @@ public:
virtual void InitInternal();
virtual void WriteInternal(const char* aBuffer, PRUint32 aCount);
virtual Telemetry::ID SpeedHistogram();
void CreateFrame(png_uint_32 x_offset, png_uint_32 y_offset,
PRInt32 width, PRInt32 height,

View File

@ -156,6 +156,9 @@ public:
void SetDecodeFlags(PRUint32 aFlags) { mDecodeFlags = aFlags; }
PRUint32 GetDecodeFlags() { return mDecodeFlags; }
// Use HistogramCount as an invalid Histogram ID
virtual Telemetry::ID SpeedHistogram() { return Telemetry::HistogramCount; }
protected:
/*

View File

@ -2775,6 +2775,13 @@ imgDecodeWorker::Run()
if (!image->mDecoder->IsSizeDecode()) {
Telemetry::Accumulate(Telemetry::IMAGE_DECODE_TIME, PRInt32(mDecodeTime.ToMicroseconds()));
// We only record the speed for some decoders. The rest have SpeedHistogram return HistogramCount.
Telemetry::ID id = image->mDecoder->SpeedHistogram();
if (id < Telemetry::HistogramCount) {
PRInt32 KBps = PRInt32((image->mBytesDecoded/1024.0)/mDecodeTime.ToSeconds());
Telemetry::Accumulate(id, KBps);
}
}
rv = image->ShutdownDecoder(RasterImage::eShutdownIntent_Done);

View File

@ -65,6 +65,7 @@
#include "nsThreadUtils.h"
#include "DiscardTracker.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/Telemetry.h"
#ifdef DEBUG
#include "imgIContainerDebug.h"
#endif

View File

@ -100,6 +100,9 @@ HISTOGRAM(IMAGE_DECODE_TIME, 50, 50000000, 100, EXPONENTIAL, "Time spent deco
HISTOGRAM(IMAGE_DECODE_ON_DRAW_LATENCY, 50, 50000000, 100, EXPONENTIAL, "Time from starting a decode to it showing up on the screen (us)")
HISTOGRAM(IMAGE_DECODE_CHUNKS, 1, 500, 50, EXPONENTIAL, "Number of chunks per decode attempt")
HISTOGRAM(IMAGE_DECODE_COUNT, 1, 500, 50, EXPONENTIAL, "Decode count")
HISTOGRAM(IMAGE_DECODE_SPEED_JPEG, 500, 50000000, 50, EXPONENTIAL, "JPEG image decode speed (Kbytes/sec)")
HISTOGRAM(IMAGE_DECODE_SPEED_GIF, 500, 50000000, 50, EXPONENTIAL, "GIF image decode speed (Kbytes/sec)")
HISTOGRAM(IMAGE_DECODE_SPEED_PNG, 500, 50000000, 50, EXPONENTIAL, "PNG image decode speed (Kbytes/sec)")
HISTOGRAM(CANVAS_2D_USED, 0, 1, 2, BOOLEAN, "2D canvas used")
HISTOGRAM(CANVAS_WEBGL_USED, 0, 1, 2, BOOLEAN, "WebGL canvas used")