Asked By
charlesc
0 points
N/A
Posted on - 02/15/2012
Hello experts,
To create my own one I need each of code or instruction to get that in the execution lifetime of a C/C++ program.
For selecting data from memory to the CPU how many times it goes to the memory and by data pitching procedure how much time is in use?
Please give me a solution.
Thanks in advance.
Execution lifetime of a C/C++ program
Hi,
To calculate the time a ‘C’ code takes to go from memory to the CPU and back again , in short the required to execute the program can be calculated by the following function.
You call in the ‘clock’ function from the lib.
#include<time.h>
intmain(void)
{
  clock_t tStart = clock();
  ** Write your code here**
   printf("Time taken: %.2fsn", (double)(clock() – tStart)/CLOCKS_PER_SEC);
  return0;
}
Just run the program and at the end , along with the result it will also display the time it took your code to complete the full cycle of execution.