mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 06:53:59 +02:00
added PerformanceWarning class
This commit is contained in:
parent
17e26b2d42
commit
16b93f8c92
2 changed files with 36 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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__) */
|
||||
|
|
Loading…
Reference in a new issue