怎么统计代码的执行时间和占用内存

求助:如何统计代码的执行时间和占用内存

请问有没有什么方法能够统计代码执行所用的时间和占用的内存,谢谢

------解决方案--------------------
任务管理器
------解决方案--------------------
#include "time.h"
/*#define CLK_TCK CLOCKS_PER_SEC*/


main()
{
unsigned int a = 0,i=100000;
float time_start, time_end;
time_start=clock();
while (in--)
{
printf ("a=%u\n",a++);
}
time_end=clock();
printf ("time=%f\n",(time_end - time_start) / CLK_TCK);
system("pause");
}
------解决方案--------------------
上面的in要改成i

#include "time.h"
/*#define CLK_TCK CLOCKS_PER_SEC*/


main()
{
unsigned int a = 0,i=100000;
float time_start, time_end;
time_start=clock();
while (i--)
{
printf ("a=%u\n",a++);
}
time_end=clock();
printf ("time=%f\n",(time_end - time_start) / CLK_TCK);
system("pause");
}
------解决方案--------------------
除非用Windows API的QueryPerformanceCounter,否则计时精度一般不超过10-15ms

内存需要分析代码(栈用了多少,堆用了多少),任务管理器的内存占用不准,因为exe调用了其他dll