I am using visual studio 2013 and i need to find out the execution time of my code(C++). Is there anyway that make me do that ?
This maybe one of the possible answer :
For Visual Studio
: go to
Tools / Options / Projects and Solutions / VC++ Project Settings
and set Build Timing
option to 'yes
'. After that the time of every build will be displayed in the Output window.
For C
#include <time.h>
int main(void)
{
clock_t tStart = clock();
/* Do your stuff here */
printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
return 0;
}
For C++
For C++11
Try to use function clock()
from <time.h>
:
#include <time.h>
#include <iostream>
int main()
{
clock_t clkStart;
clock_t clkFinish;
clkStart = clock();
for(int i = 0; i < 10000000; i++)
;
//other code
clkFinish = clock();
std::cout << clkFinish - clkStart;
system("pause");
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With