mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1285865 (Part 2) - Add a RAII class to record decoder telemetry. r=edwin
This commit is contained in:
parent
a50b8d5f3e
commit
b9c1cec011
@ -22,6 +22,34 @@ using mozilla::gfx::SurfaceFormat;
|
||||
namespace mozilla {
|
||||
namespace image {
|
||||
|
||||
class MOZ_STACK_CLASS AutoRecordDecoderTelemetry final
|
||||
{
|
||||
public:
|
||||
AutoRecordDecoderTelemetry(Decoder* aDecoder, uint32_t aByteCount)
|
||||
: mDecoder(aDecoder)
|
||||
{
|
||||
MOZ_ASSERT(mDecoder);
|
||||
|
||||
// Begin recording telemetry data.
|
||||
mStartTime = TimeStamp::Now();
|
||||
mDecoder->mChunkCount++;
|
||||
|
||||
// Keep track of the total number of bytes written.
|
||||
mDecoder->mBytesDecoded += aByteCount;
|
||||
|
||||
}
|
||||
|
||||
~AutoRecordDecoderTelemetry()
|
||||
{
|
||||
// Finish telemetry.
|
||||
mDecoder->mDecodeTime += (TimeStamp::Now() - mStartTime);
|
||||
}
|
||||
|
||||
private:
|
||||
Decoder* mDecoder;
|
||||
TimeStamp mStartTime;
|
||||
};
|
||||
|
||||
Decoder::Decoder(RasterImage* aImage)
|
||||
: mImageData(nullptr)
|
||||
, mImageDataLength(0)
|
||||
@ -142,18 +170,10 @@ Decoder::Write(const char* aBuffer, uint32_t aCount)
|
||||
MOZ_ASSERT(aBuffer);
|
||||
MOZ_ASSERT(aCount > 0);
|
||||
|
||||
// Begin recording telemetry data.
|
||||
TimeStamp start = TimeStamp::Now();
|
||||
mChunkCount++;
|
||||
|
||||
// Keep track of the total number of bytes written.
|
||||
mBytesDecoded += aCount;
|
||||
AutoRecordDecoderTelemetry telemetry(this, aCount);
|
||||
|
||||
// Pass the data along to the implementation.
|
||||
WriteInternal(aBuffer, aCount);
|
||||
|
||||
// Finish telemetry.
|
||||
mDecodeTime += (TimeStamp::Now() - start);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -272,6 +272,7 @@ public:
|
||||
|
||||
|
||||
protected:
|
||||
friend class AutoRecordDecoderTelemetry;
|
||||
friend class nsICODecoder;
|
||||
friend class PalettedSurfaceSink;
|
||||
friend class SurfaceSink;
|
||||
|
Loading…
Reference in New Issue
Block a user