I have the following C++ code (I have simplified it for the sake of simplicity.)
int main()
{
string runCommand="./runAnotherCppProgram.out";
for (int i=0; i<5; i++)
{
system(runCommand.c_str());
}
return 0;
}
Now I want to know how much time does runAnotherCppProgram.out take at each iteration. To do this I did the following thing:
int main()
{
string runCommand = "./runAnotherCppProgram.out";
for (int i=0; i<5; i++)
{
clock_t clockStart = clock();
system(runCommand.c_str());
double finish = (double)(clock() - clockStart)/CLOCKS_PER_SEC;
cout << finish << endl;
}
return 0;
}
However, it gives much less then the real time of executing. What might be the problem?
time anotherprogramto get this on shell and cross verify