summaryrefslogtreecommitdiff
path: root/indra/llimage
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llimage')
-rw-r--r--indra/llimage/llimagej2c.cpp131
-rw-r--r--indra/llimage/llimagej2c.h40
2 files changed, 171 insertions, 0 deletions
diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp
index c8c866b7f2..207728d4d9 100644
--- a/indra/llimage/llimagej2c.cpp
+++ b/indra/llimage/llimagej2c.cpp
@@ -30,6 +30,7 @@
#include "lldir.h"
#include "llimagej2c.h"
#include "llmemtype.h"
+#include "lltimer.h"
typedef LLImageJ2CImpl* (*CreateLLImageJ2CFunction)();
typedef void (*DestroyLLImageJ2CFunction)(LLImageJ2CImpl*);
@@ -51,6 +52,9 @@ LLImageJ2CImpl* fallbackCreateLLImageJ2CImpl();
void fallbackDestroyLLImageJ2CImpl(LLImageJ2CImpl* impl);
const char* fallbackEngineInfoLLImageJ2CImpl();
+// Test data gathering handle
+LLImageCompressionTester* LLImageJ2C::sTesterp = NULL ;
+
//static
//Loads the required "create", "destroy" and "engineinfo" functions needed
void LLImageJ2C::openDSO()
@@ -195,6 +199,16 @@ LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C),
{ // Array size is MAX_DISCARD_LEVEL+1
mDataSizes[i] = 0;
}
+
+ if (LLFastTimer::sMetricLog && !LLImageJ2C::sTesterp)
+ {
+ LLImageJ2C::sTesterp = new LLImageCompressionTester() ;
+ if (!LLImageJ2C::sTesterp->isValid())
+ {
+ delete LLImageJ2C::sTesterp;
+ LLImageJ2C::sTesterp = NULL;
+ }
+ }
}
// virtual
@@ -280,6 +294,7 @@ BOOL LLImageJ2C::decode(LLImageRaw *raw_imagep, F32 decode_time)
// Returns TRUE to mean done, whether successful or not.
BOOL LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 first_channel, S32 max_channel_count )
{
+ LLTimer elapsed;
LLMemType mt1(mMemType);
BOOL res = TRUE;
@@ -318,6 +333,20 @@ BOOL LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 fir
LLImage::setLastError(mLastError);
}
+ if (LLImageJ2C::sTesterp)
+ {
+ // Decompression stat gathering
+ // Note that we *do not* take into account the decompression failures data so we night overestimate the time spent processing
+
+ // Always add the decompression time to the stat
+ LLImageJ2C::sTesterp->updateDecompressionStats(elapsed.getElapsedTimeF32()) ;
+ if (res)
+ {
+ // The whole data stream is finally decompressed when res is returned as TRUE
+ LLImageJ2C::sTesterp->updateDecompressionStats(this->getDataSize(), raw_imagep->getDataSize()) ;
+ }
+ }
+
return res;
}
@@ -330,6 +359,7 @@ BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, F32 encode_time)
BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, const char* comment_text, F32 encode_time)
{
+ LLTimer elapsed;
LLMemType mt1(mMemType);
resetLastError();
BOOL res = mImpl->encodeImpl(*this, *raw_imagep, comment_text, encode_time, mReversible);
@@ -337,6 +367,22 @@ BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, const char* comment_text,
{
LLImage::setLastError(mLastError);
}
+
+ if (LLImageJ2C::sTesterp)
+ {
+ // Compression stat gathering
+ // Note that we *do not* take into account the compression failures cases so we night overestimate the time spent processing
+
+ // Always add the compression time to the stat
+ LLImageJ2C::sTesterp->updateCompressionStats(elapsed.getElapsedTimeF32()) ;
+ if (res)
+ {
+ // The whole data stream is finally compressed when res is returned as TRUE
+ LLImageJ2C::sTesterp->updateCompressionStats(this->getDataSize(), raw_imagep->getDataSize()) ;
+ }
+ }
+
+
return res;
}
@@ -540,3 +586,88 @@ void LLImageJ2C::updateRawDiscardLevel()
LLImageJ2CImpl::~LLImageJ2CImpl()
{
}
+
+//----------------------------------------------------------------------------------------------
+// Start of LLImageCompressionTester
+//----------------------------------------------------------------------------------------------
+LLImageCompressionTester::LLImageCompressionTester() : LLMetricPerformanceTesterBasic("ImageCompressionTester")
+{
+ addMetric("TotalBytesInDecompression");
+ addMetric("TotalBytesOutDecompression");
+ addMetric("TotalBytesInCompression");
+ addMetric("TotalBytesOutCompression");
+
+ addMetric("TimeTimeDecompression");
+ addMetric("TimeTimeCompression");
+
+ mTotalBytesInDecompression = 0;
+ mTotalBytesOutDecompression = 0;
+ mTotalBytesInCompression = 0;
+ mTotalBytesOutCompression = 0;
+
+ mTotalTimeDecompression = 0.0f;
+ mTotalTimeCompression = 0.0f;
+}
+
+LLImageCompressionTester::~LLImageCompressionTester()
+{
+ LLImageJ2C::sTesterp = NULL;
+}
+
+//virtual
+void LLImageCompressionTester::outputTestRecord(LLSD *sd)
+{
+ std::string currentLabel = getCurrentLabelName();
+ (*sd)[currentLabel]["TotalBytesInDecompression"] = (LLSD::Integer)mTotalBytesInDecompression;
+ (*sd)[currentLabel]["TotalBytesOutDecompression"] = (LLSD::Integer)mTotalBytesOutDecompression;
+ (*sd)[currentLabel]["TotalBytesInCompression"] = (LLSD::Integer)mTotalBytesInCompression;
+ (*sd)[currentLabel]["TotalBytesOutCompression"] = (LLSD::Integer)mTotalBytesOutCompression;
+
+ (*sd)[currentLabel]["TimeTimeDecompression"] = (LLSD::Real)mTotalTimeDecompression;
+ (*sd)[currentLabel]["TimeTimeCompression"] = (LLSD::Real)mTotalTimeCompression;
+}
+
+void LLImageCompressionTester::updateCompressionStats(const F32 deltaTime)
+{
+ mTotalTimeCompression += deltaTime;
+}
+
+void LLImageCompressionTester::updateCompressionStats(const S32 bytesCompress, const S32 bytesRaw)
+{
+ mTotalBytesInCompression += bytesRaw;
+ mTotalBytesOutCompression += bytesCompress;
+ if (mTotalBytesInCompression > (1000000))
+ {
+ // Output everything
+ outputTestResults();
+ // Reset only the compression data
+ mTotalBytesInCompression = 0;
+ mTotalBytesOutCompression = 0;
+ mTotalTimeCompression = 0.0f;
+ }
+}
+
+void LLImageCompressionTester::updateDecompressionStats(const F32 deltaTime)
+{
+ mTotalTimeDecompression += deltaTime;
+}
+
+void LLImageCompressionTester::updateDecompressionStats(const S32 bytesIn, const S32 bytesOut)
+{
+ mTotalBytesInDecompression += bytesIn;
+ mTotalBytesOutDecompression += bytesOut;
+ if (mTotalBytesInDecompression > (5*1000000))
+ {
+ // Output everything
+ outputTestResults();
+ // Reset only the decompression data
+ mTotalBytesInDecompression = 0;
+ mTotalBytesOutDecompression = 0;
+ mTotalTimeDecompression = 0.0f;
+ }
+}
+
+//----------------------------------------------------------------------------------------------
+// End of LLTexturePipelineTester
+//----------------------------------------------------------------------------------------------
+
diff --git a/indra/llimage/llimagej2c.h b/indra/llimage/llimagej2c.h
index cdb3faa207..adbfb9cdb3 100644
--- a/indra/llimage/llimagej2c.h
+++ b/indra/llimage/llimagej2c.h
@@ -29,8 +29,11 @@
#include "llimage.h"
#include "llassettype.h"
+#include "llmetricperformancetester.h"
class LLImageJ2CImpl;
+class LLImageCompressionTester ;
+
class LLImageJ2C : public LLImageFormatted
{
protected:
@@ -72,6 +75,9 @@ public:
static void openDSO();
static void closeDSO();
static std::string getEngineInfo();
+
+ // Image compression/decompression tester
+ static LLImageCompressionTester* sTesterp ;
protected:
friend class LLImageJ2CImpl;
@@ -118,4 +124,38 @@ protected:
#define LINDEN_J2C_COMMENT_PREFIX "LL_"
+//
+// This class is used for performance data gathering only.
+// Tracks the image compression / decompression data,
+// records and outputs them to metric.slp log files.
+//
+class LLImageCompressionTester : public LLMetricPerformanceTesterBasic
+{
+ public:
+ LLImageCompressionTester();
+ ~LLImageCompressionTester();
+
+ void updateDecompressionStats(const F32 deltaTime) ;
+ void updateDecompressionStats(const S32 bytesIn, const S32 bytesOut) ;
+ void updateCompressionStats(const F32 deltaTime) ;
+ void updateCompressionStats(const S32 bytesIn, const S32 bytesOut) ;
+
+ protected:
+ /*virtual*/ void outputTestRecord(LLSD* sd);
+
+ private:
+ //
+ // Data size
+ //
+ U32 mTotalBytesInDecompression; // Total bytes fed to decompressor
+ U32 mTotalBytesOutDecompression; // Total bytes produced by decompressor
+ U32 mTotalBytesInCompression; // Total bytes fed to compressor
+ U32 mTotalBytesOutCompression; // Total bytes produced by compressor
+ //
+ // Time
+ //
+ F32 mTotalTimeDecompression; // Total time spent in computing decompression
+ F32 mTotalTimeCompression; // Total time spent in computing compression
+ };
+
#endif