42 m_idPtr->Increment(
add);
48 m_idPtr->Maximum(
max);
53 return m_idPtr?m_idPtr->GetName():
NULL;
58 return m_idPtr?m_idPtr->GetDescr():
NULL;
63 return m_idPtr?m_idPtr->GetUnit():
NULL;
68 return m_idPtr?m_idPtr->AsString(m_idPtr->GetCurrentValue()):
NULL;
74 if (!m_idPtr||!m_idPtr->GetFrameValue(frame,v))
76 return m_idPtr->AsString(v);
81 return m_idPtr?m_idPtr->AsString(m_idPtr->GetTotalValue()):
NULL;
87ProfileHighLevel::Block::Block(
const char *name)
94 strncpy(help,name,
sizeof(help));
95 help[
sizeof(help)-1-2]=0;
116int ProfileId::curFrame;
117unsigned ProfileId::frameRecordMask;
118char ProfileId::stringBuf[ProfileId::STRING_BUFFER_SIZE];
119unsigned ProfileId::stringBufUnused;
121ProfileId::ProfileId(
const char *name,
const char *descr,
const char *unit,
int precision,
int exp10)
123 m_next=first; first=
this;
129 strcpy(m_descr,descr);
140 m_precision=precision;
142 m_curVal=m_totalVal=0.;
144 m_firstFrame=curFrame;
150 DFAIL_IF(m_valueMode!=Unknown&&m_valueMode!=ModeIncrement)
153 m_valueMode=ModeIncrement;
158 unsigned mask=frameRecordMask;
159 for (
unsigned i=0;i<MAX_FRAME_RECORDS;i++)
171 DFAIL_IF(m_valueMode!=Unknown&&m_valueMode!=ModeMaximum)
174 m_valueMode=ModeMaximum;
181 unsigned mask=frameRecordMask;
182 for (
unsigned i=0;i<MAX_FRAME_RECORDS;i++)
186 if (
max>m_frameVal[i])
197 char help1[10],help[40];
198 wsprintf(help1,
"%%%i.lf",m_precision);
202 for (k=m_exp10;k<0;k++) mul*=10.0;
203 for (;k>0;k--) mul/=10.0;
205 unsigned len=_snprintf(help,
sizeof(help),help1,v*mul)+1;
208 if (stringBufUnused+len>STRING_BUFFER_SIZE)
210 char *ret=stringBuf+stringBufUnused;
211 memcpy(ret,help,len);
212 stringBufUnused+=len;
220 for (
unsigned i=0;i<MAX_FRAME_RECORDS;i++)
221 if (!(frameRecordMask&(1<<i)))
223 if (i==MAX_FRAME_RECORDS)
226 for (ProfileId *p=first;p;p=p->m_next)
229 frameRecordMask|=1<<i;
235 DFAIL_IF(which<0||which>=MAX_FRAME_RECORDS)
237 DFAIL_IF(!(frameRecordMask&(1<<which)))
244 frameRecordMask^=1<<which;
249 for (ProfileId *p=first;p;p=p->m_next)
251 p->m_recFrameVal=(
double *)
ProfileReAllocMemory(p->m_recFrameVal,
sizeof(
double)*(curFrame-p->m_firstFrame));
252 p->m_recFrameVal[curFrame-p->m_firstFrame-1]=p->m_frameVal[which];
258 for (ProfileId *p=first;p;p=p->m_next)
260 if (p->m_firstFrame>mixIndex)
263 double &val=p->m_recFrameVal[mixIndex-p->m_firstFrame];
264 switch(p->m_valueMode)
266 case ProfileId::Unknown:
268 case ProfileId::ModeIncrement:
269 val+=p->m_frameVal[which];
271 case ProfileId::ModeMaximum:
272 if (p->m_frameVal[which]>val)
273 val=p->m_frameVal[which];
286 for (
unsigned i=0;i<MAX_FRAME_RECORDS;i++)
287 if (frameRecordMask&(1<<i))
325 if (!strcmp(name,cur->GetName()))
335ProfileHighLevel::ProfileHighLevel(
void)
339ProfileHighLevel ProfileHighLevel::Instance;
__forceinline void ProfileGetTime(__int64 &t)
void add(float *sum, float *addend)
~Block()
Updates timer based function block.
const char * GetName(void) const
Returns the internal Id name.
const char * GetCurrentValue(void) const
Returns the current value.
void SetMax(double max)
Set a new maximum value.
const char * GetUnit(void) const
Returns the value's unit text.
const char * GetValue(unsigned frame) const
Returns the value for the given recorded frame/range.
void Increment(double add=1.0)
Increment the internal profile value.
const char * GetDescr(void) const
Returns the descriptive name.
const char * GetTotalValue(void) const
Returns the total value for all frames.
static bool FindProfile(const char *name, Id &id)
Searches for the given high level profile.
static bool EnumProfile(unsigned index, Id &id)
Enumerates the list of known high level profile values.
static Id AddProfile(const char *name, const char *descr, const char *unit, int precision, int exp10=0)
Registers a new high level profile value.
static _int64 GetClockCyclesPerSecond(void)
Determines number of CPU clock cycles per second.
an internal high level profile ID
static int FrameStart(void)
void Increment(double add)
static ProfileId * GetFirst(void)
static void Shutdown(void)
const char * AsString(double v) const
static void FrameEnd(int which, int mixIndex)
void * ProfileReAllocMemory(void *oldPtr, unsigned newSize)
void * ProfileAllocMemory(unsigned numBytes)