Execution lifetime of a C/C++ program

Asked By 0 points N/A Posted on -

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.

Answered By 0 points N/A #98441

Execution lifetime of a C/C++ program


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.




    clock_t tStart = clock();

    ** Write your code here**

    printf("Time taken: %.2fsn", (double)(clock() – tStart)/CLOCKS_PER_SEC);



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.

Related Questions