46 sprintf(help,
"prof%08x-all.csv",thread.GetId());
47 FILE *f=fopen(help,
"wt");
50 fprintf(f,
"Function\tFile\tCall count\tPTT (all)\tGTT (all)\tPT/C (all)\tGT/C (all)\tCaller (all)");
54 fprintf(f,
"\tCall (%s)\tPTT (%s)\tGTT (%s)\tPT/C (%s)\tGT/C (%s)\tCaller (%s)",s,s,s,s,s,s);
59 ProfileFuncLevel::Id id;
62 fprintf(f,
"%s[%08x]\t%s, %i",
id.GetFunction(),
id.GetAddress(),
63 id.GetSource(),
id.GetLine());
70 fprintf(f,
"\t\t\t\t\t\t");
75 fprintf(f,
"\t%I64i",
id.GetCalls(i));
78 fprintf(f,
"\t%I64i",
id.GetFunctionTime(i));
81 fprintf(f,
"\t%I64i",
id.GetTime(i));
84 fprintf(f,
"\t%I64i",
id.GetFunctionTime(i)/
id.GetCalls(i));
87 fprintf(f,
"\t%I64i",
id.GetTime(i)/
id.GetCalls(i));
90 ProfileFuncLevel::IdList idlist=
id.GetCaller(i);
92 ProfileFuncLevel::Id callid;
94 for (
unsigned j=0;idlist.
Enum(j,callid,&count);j++)
109 FILE *f=fopen(
"profile-high.csv",
"wt");
112 fprintf(f,
"Profile\tUnit\ttotal");
121 fprintf(f,
"%s\t%s\t%s",
id.
GetName(),
id.GetUnit(),
id.GetTotalValue());
124 const char *p=
id.GetValue(i);
125 fprintf(f,
"\t%s",p?p:
"");
135 this->~ProfileResultFileCSV();
145 ProfileResultFileDOT(argn>0?argv[0]:
NULL,
147 argn>2?atoi(argv[2]):
NULL);
150ProfileResultFileDOT::ProfileResultFileDOT(
const char *fileName,
const char *frameName,
int foldThreshold)
153 fileName=
"profile.dot";
155 strcpy(m_fileName,fileName);
159 strcpy(m_frameName,frameName);
163 m_foldThreshold=foldThreshold;
206 if (
id.GetCalls(frame))
209 FILE *f=fopen(m_fileName,
"wt");
214 fprintf(f,
"digraph G { rankdir=\"LR\";\n");
215 fprintf(f,
"node [shape=box, fontname=Arial]\n");
216 fprintf(f,
"edge [arrowhead=%s, labelfontname=Arial, labelfontsize=10, labelangle=0, labelfontcolor=blue]\n",
217 active>m_foldThreshold?
"closed":
"none");
220 if (active>m_foldThreshold)
225 FoldHelper *fold=
NULL;
228 const char *source=
id.GetSource();
229 for (FoldHelper *cur=fold;cur;cur=cur->next)
230 if (!strcmp(source,cur->source))
233 cur->id[cur->numId++]=id;
248 for (FoldHelper *cur=fold;cur;cur=cur->next)
250 for (FoldHelper *cur2=fold;cur2;cur2=cur2->next)
253 for (k=0;k<cur->numId;k++)
257 for (
unsigned i=0;idlist.
Enum(i,caller);i++)
260 for (FoldHelper *cur2=fold;cur2;cur2=cur2->next)
261 if (!strcmp(cur2->source,s))
263 if (!cur2||cur2->mark)
267 fprintf(f,
"\"%s\" -> \"%s\"\n",s,cur->source);
275 FoldHelper *next=fold->next;
284 if (
id.GetCalls(frame))
285 fprintf(f,
"f%08x [label=\"%s\"]\n",
id.GetAddress(),
id.GetFunction());
291 for (
unsigned i=0;idlist.
Enum(i,caller,&count);i++)
292 fprintf(f,
"f%08x -> f%08x [headlabel=\"%i\"];\n",caller.
GetAddress(),
id.GetAddress(),count);
302 this->~ProfileResultFileDOT();
A function level profile ID.
unsigned GetAddress(void) const
Returns function address.
@ Total
return the total value/count
const char * GetSource(void) const
Returns the source file this Id is in.
const char * GetFunction(void) const
Returns the function name for this Id.
A list of function level profile IDs.
bool Enum(unsigned index, Id &id, unsigned *countPtr=0) const
Enumerates the list of IDs.
bool EnumProfile(unsigned index, Id &id) const
Enumerates the list of known function level profile values.
static bool EnumThreads(unsigned index, Thread &thread)
Enumerates the list of known and profiled threads.
static bool EnumProfile(unsigned index, Id &id)
Enumerates the list of known high level profile values.
static unsigned GetFrameCount(void)
Determines the number of known (recorded) range frames.
static const char * GetFrameName(unsigned frame)
Determines the range name of a recorded range frame.
virtual const char * GetName(void) const
static ProfileResultInterface * Create(int argn, const char *const *)
virtual void WriteResults(void)
Write out results.
virtual void Delete(void)
Destroys the current result function.
static ProfileResultInterface * Create(int argn, const char *const *)
Creates a class instance.
virtual void WriteResults(void)
Write out results.
virtual void Delete(void)
Destroys the current result function.
void ProfileFreeMemory(void *ptr)
void * ProfileAllocMemory(unsigned numBytes)