I would like to measure how long a particular operation takes, therefore I've written the following piece of code:
for (int counter2 = 0; counter2 <= 10; counter2++) { // I'll do the test 10 times,
// for having reliable results
time_t ltime;
time(<ime); // What's the time at the beginning?
for (counter = 0; counter <= 1000000; counter++) {
Do_Something();
}
time_t ltime2;
time(<ime2); // What's the time after having launched Do_Something()?
printf("Times:First=[%d], Second=[%d]\n", ltime, ltime2);
}
I'm expecting something like:
Times: First=[1559574983], Second=[1559574985]
Times: First=[1559574990], Second=[1559574999]
Instead I get this:
Times: First=[1559574983], Second=[0]
Times: First=[1559574990], Second=[0]
I've already debugged, and ltime2
seems to be correct. What am I doing wrong?