diff --git a/modules/libpr0n/decoders/nsGIFDecoder2.cpp b/modules/libpr0n/decoders/nsGIFDecoder2.cpp index 8a19a759574e..e1a36015ba45 100644 --- a/modules/libpr0n/decoders/nsGIFDecoder2.cpp +++ b/modules/libpr0n/decoders/nsGIFDecoder2.cpp @@ -1096,5 +1096,12 @@ done: return; } +Telemetry::ID +nsGIFDecoder2::SpeedHistogram() +{ + return Telemetry::IMAGE_DECODE_SPEED_GIF; +} + + } // namespace imagelib } // namespace mozilla diff --git a/modules/libpr0n/decoders/nsGIFDecoder2.h b/modules/libpr0n/decoders/nsGIFDecoder2.h index 629332c17bb1..a9c419ac2a2d 100644 --- a/modules/libpr0n/decoders/nsGIFDecoder2.h +++ b/modules/libpr0n/decoders/nsGIFDecoder2.h @@ -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, diff --git a/modules/libpr0n/decoders/nsJPEGDecoder.cpp b/modules/libpr0n/decoders/nsJPEGDecoder.cpp index 9806b7bd0359..abb2b3f1a855 100644 --- a/modules/libpr0n/decoders/nsJPEGDecoder.cpp +++ b/modules/libpr0n/decoders/nsJPEGDecoder.cpp @@ -153,6 +153,11 @@ nsJPEGDecoder::~nsJPEGDecoder() this)); } +Telemetry::ID +nsJPEGDecoder::SpeedHistogram() +{ + return Telemetry::IMAGE_DECODE_SPEED_JPEG; +} void nsJPEGDecoder::InitInternal() diff --git a/modules/libpr0n/decoders/nsJPEGDecoder.h b/modules/libpr0n/decoders/nsJPEGDecoder.h index 74c83a6b4453..ecee5ccfebb7 100644 --- a/modules/libpr0n/decoders/nsJPEGDecoder.h +++ b/modules/libpr0n/decoders/nsJPEGDecoder.h @@ -93,6 +93,7 @@ public: virtual void WriteInternal(const char* aBuffer, PRUint32 aCount); virtual void FinishInternal(); + virtual Telemetry::ID SpeedHistogram(); void NotifyDone(); protected: diff --git a/modules/libpr0n/decoders/nsPNGDecoder.cpp b/modules/libpr0n/decoders/nsPNGDecoder.cpp index f6e67cae6130..ed1415c9c2a0 100644 --- a/modules/libpr0n/decoders/nsPNGDecoder.cpp +++ b/modules/libpr0n/decoders/nsPNGDecoder.cpp @@ -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 diff --git a/modules/libpr0n/decoders/nsPNGDecoder.h b/modules/libpr0n/decoders/nsPNGDecoder.h index 39bba8fe92cb..58747986acf0 100644 --- a/modules/libpr0n/decoders/nsPNGDecoder.h +++ b/modules/libpr0n/decoders/nsPNGDecoder.h @@ -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, diff --git a/modules/libpr0n/src/Decoder.h b/modules/libpr0n/src/Decoder.h index f42c98c61f63..5053e8a61b94 100644 --- a/modules/libpr0n/src/Decoder.h +++ b/modules/libpr0n/src/Decoder.h @@ -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: /* diff --git a/modules/libpr0n/src/RasterImage.cpp b/modules/libpr0n/src/RasterImage.cpp index 43206523b887..f3a27d613533 100644 --- a/modules/libpr0n/src/RasterImage.cpp +++ b/modules/libpr0n/src/RasterImage.cpp @@ -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); diff --git a/modules/libpr0n/src/RasterImage.h b/modules/libpr0n/src/RasterImage.h index fc28dde4c5b3..f305d5ed51c2 100644 --- a/modules/libpr0n/src/RasterImage.h +++ b/modules/libpr0n/src/RasterImage.h @@ -65,6 +65,7 @@ #include "nsThreadUtils.h" #include "DiscardTracker.h" #include "mozilla/TimeStamp.h" +#include "mozilla/Telemetry.h" #ifdef DEBUG #include "imgIContainerDebug.h" #endif diff --git a/toolkit/components/telemetry/TelemetryHistograms.h b/toolkit/components/telemetry/TelemetryHistograms.h index 487948435f66..47f332fc0475 100644 --- a/toolkit/components/telemetry/TelemetryHistograms.h +++ b/toolkit/components/telemetry/TelemetryHistograms.h @@ -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")