Inserisci all'inizio del blocco da monitorare una cosa tipo
codice:
LARGE_INTEGER beginCount,endCount,frequency;
QueryPerformanceFrequency(&frequency);
QueryPerformanceCounter(&beginCount);
e alla fine
codice:
QueryPerformanceCounter(&endCount);
double secs=(endCount.QuadPart-beginCount.QuadPart)/(double)frequency.QuadPart;
Ora in secs ci sono i secondi trascorsi, che puoi visualizzare come meglio credi (ad esempio con una MessageBox:
codice:
TCHAR buffer[512];
_sntprintf(buffer,ARRSIZE(buffer),_T("%f"),secs);
MessageBox(0,buffer,_T("Debug message"),MB_ICONINFORMATION);
/*
nota: ARRSIZE è definito come
#define ARRSIZE(arr) (sizeof(arr)/sizeof(*arr))
*/
).
Per l'utilizzo della memoria puoi fare lo stesso mestiere con la GetProcessMemoryInfo; tieni conto che la GetProcessMemoryInfo funziona solo sulle versioni NT di Windows (quindi NT, 2000, XP e Vista).