Hi there!
My aim is to analyse a couple of code-segments. I want to know how
much time is spent at their execution. I successfuly wrapped
QueryPerformanceCounter for that purpose. But my solution needs
unique "taskIDs", as shown in the example below. I hope this scratch
is self-explanatory:
////////////////////////////////////////////////////////
// Example
////////////////////////////////////////////////////////
CMonitor monitor (/*maxCount of Tasks to monitor*/ 20);
main()
{
monitor.Enter(/*taskID*/ 0, /*taskName*/ "main");
for (int i = 0; i < 10; i++)
{
monitor.Enter(/*taskID*/ 1, /*taskName*/ "loopBody");
func(i);
monitor.LeaveLast();
}
monitor.LeaveLast();
monitor.Save(/*filename*/ "taskdata.txt");
}
func (int i)
{
monitor.Enter(/*taskID*/ 2, /*taskName*/ "func");
i = i*(i+1);
monitor.LeaveLast();
}
////////////////////////////////////////////////////////
monitor.Enter() determines whether it is the first time you Enter
that task and (in that case) initializes internal Data. Otherwise
it skips initialization for that ID.
I want to replace
/*taskID*/ 0
/*taskID*/ 1
/*taskID*/ 2
by something like
#define TASKID 0
TASKID++
TASKID++
TASKID++
I want the Precompiler to increment if that is possible - because it
would be quite efficient at runtime and convenient while programming.
As I don't expect such functionality - does anyone know a workaround?
Thank you in advance!
Colin