Description of Problem
Below I have a program that is performing two simple addition and multiplication operations. I am then storing the sum of these two simple operations in two respective variables called total1 and total2. In terms of computation total2 will take more time to be fully executed. The way I implemented the code, I am currently timing the entire simulation of both mathematical operations.
Question
Is it possible to time solely the end result of total1 and total 2 separately? I am asking so as I wish to get the specific time of total1 and total2 in a separate manner.
Purpose of Task
I am fully aware that long long is expensive with regards to memory and is not the most efficient way to save up memory. The sole purpose of this code and question is timing and not code optimization.
C Code
#include <stdio.h>
#include <time.h>
int main()
{
long long total1 = 0, total2 = 0, i = 0;
double simulation_time = 0;
clock_t Start = clock();
do
{
total1 += i + i;
total2 += i * i * i * i;
i++;
} while (i < 1000000000);
clock_t End = clock();
printf("Total 1 = %u \n", total1);
printf("Total 2 = %u \n", total2);
simulation_time = (double)(End - Start) / CLOCKS_PER_SEC;
printf("Runtime of Whole Simulation using clock_t: %f\n", simulation_time);
return 0;
}