I have finished writing a function and I want to compare time and cpu execution of the function with other function. This is code to calculate time execution but I not sure it accuracy. Do you have accuracy code to calculate time and cpu spending for one function in C++?
//Only time execution. CPU spending?
#include "stdafx.h"
#include <iostream>
#include <time.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
clock_t start, end;
start = clock();
for(int i=0;i<65536;i++)
cout<<i<<endl;
end = clock();
cout << "Time required for execution: "
<< (double)(end-start)/CLOCKS_PER_SEC
<< " seconds." << "\n\n";
return 0;
}