2012-10-06 21:52:26 +00:00
|
|
|
#ifndef __BLOCK_STATS_H__
|
|
|
|
#define __BLOCK_STATS_H__
|
|
|
|
|
|
|
|
#include "TexCompTypes.h"
|
|
|
|
#include "ReferenceCounter.h"
|
|
|
|
#include "Thread.h"
|
|
|
|
|
|
|
|
struct BlockStat {
|
|
|
|
friend class BlockStatManager;
|
|
|
|
public:
|
2012-10-07 02:25:49 +00:00
|
|
|
BlockStat(const CHAR *statName, int);
|
2012-10-06 21:52:26 +00:00
|
|
|
BlockStat(const CHAR *statName, double stat);
|
|
|
|
|
|
|
|
BlockStat(const BlockStat &);
|
|
|
|
BlockStat &operator=(const BlockStat &);
|
2012-11-01 22:56:13 +00:00
|
|
|
|
|
|
|
void ToString(char *buf, int bufSz) const;
|
2012-10-06 21:52:26 +00:00
|
|
|
|
|
|
|
private:
|
2012-10-08 17:16:41 +00:00
|
|
|
const enum Type {
|
|
|
|
eType_Float,
|
|
|
|
eType_Int,
|
|
|
|
|
|
|
|
kNumTypes
|
|
|
|
} m_Type;
|
|
|
|
|
2012-10-06 21:52:26 +00:00
|
|
|
static const int kStatNameSz = 32;
|
2012-10-07 04:34:06 +00:00
|
|
|
CHAR m_StatName[kStatNameSz];
|
2012-10-06 21:52:26 +00:00
|
|
|
union {
|
|
|
|
uint64 m_IntStat;
|
|
|
|
double m_FloatStat;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
class BlockStatManager {
|
|
|
|
|
|
|
|
public:
|
|
|
|
BlockStatManager(int nBlocks);
|
|
|
|
~BlockStatManager();
|
|
|
|
|
|
|
|
uint32 BeginBlock();
|
|
|
|
void AddStat(uint32 blockIdx, const BlockStat &stat);
|
2012-10-07 04:34:06 +00:00
|
|
|
void ToFile(const CHAR *filename);
|
2012-10-06 21:52:26 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
class BlockStatList {
|
|
|
|
public:
|
|
|
|
BlockStatList();
|
|
|
|
~BlockStatList();
|
|
|
|
|
|
|
|
void AddStat(const BlockStat &stat);
|
2012-10-07 04:34:06 +00:00
|
|
|
BlockStat GetStat() const { return m_Stat; }
|
|
|
|
const BlockStatList *GetTail() const { return m_Tail; }
|
2012-10-06 21:52:26 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
BlockStatList(const BlockStat &stat);
|
|
|
|
|
|
|
|
BlockStat m_Stat;
|
|
|
|
BlockStatList *m_Tail;
|
|
|
|
|
|
|
|
ReferenceCounter m_Counter;
|
|
|
|
} *m_BlockStatList;
|
|
|
|
uint32 m_BlockStatListSz;
|
|
|
|
|
|
|
|
TCMutex m_Mutex;
|
|
|
|
uint32 m_NextBlock;
|
|
|
|
ReferenceCounter m_Counter;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __BLOCK_STATS_H__
|