简体   繁体   中英

How to Find Execution Time and Memory usage of a program in c

I have made a application program in c language. And now i am trying to find Execution time and memory usage of my program. I have tried using time.h header and had done following dif_sec = (double) difftime (time2,time1); But every time i run the program, it give different execution time. For eg. : 1st time i got 19 millisecond, and if i again i run the same program it will give me different execution time, greater then 19 millisecond, around 28 millisecond. And some time it give around 150 millisecond. So i am trying to get perfect execution time. And also need a help to find memory usage of a program. I am running my program on CodeBlocks in windows.

For Windows programs you can use QueryPerformanceCounter and QueryPerformanceFrequency to measure times to a decent accuracy. There's an article here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM