added PerformanceWarning class

This commit is contained in:
ZappoMan 2013-05-06 11:00:01 -07:00
parent 17e26b2d42
commit 16b93f8c92
2 changed files with 36 additions and 0 deletions

View file

@ -103,3 +103,28 @@ int PerfStat::DumpStats(char** array) {
return lineCount;
}
// Constructor handles starting the warning timer
PerformanceWarning::PerformanceWarning(bool renderWarnings, const char* message) {
_start = usecTimestampNow();
_message = message;
_renderWarningsOn = renderWarnings;
// need to also store the args...
}
// Destructor handles recording all of our stats
PerformanceWarning::~PerformanceWarning() {
double end = usecTimestampNow();
double elapsedmsec = (end - _start)/1000.0;
if (_renderWarningsOn && elapsedmsec > 1) {
if (elapsedmsec > 1000) {
double elapsedsec = (end - _start)/1000000.0;
printLog("WARNING! %s took %lf seconds\n", _message, elapsedsec);
} else {
printLog("WARNING! %s took %lf milliseconds\n", _message, elapsedmsec);
}
}
};

View file

@ -13,6 +13,7 @@
#define __hifi__PerfStat__
#include <stdint.h>
#include "SharedUtil.h"
#ifdef _WIN32
#define snprintf _snprintf
@ -81,5 +82,15 @@ public:
typedef std::map<std::string,PerfStatHistory,std::less<std::string> >::iterator PerfStatMapItr;
class PerformanceWarning {
private:
double _start;
const char* _message;
bool _renderWarningsOn;
public:
PerformanceWarning(bool renderWarnings, const char* message);
~PerformanceWarning();
};
#endif /* defined(__hifi__PerfStat__) */