iwas wondering how i can get the CPU time from the start of afunction and the CPU time of the end of the function and then takeboth times to figure out the total time. All this needs to be inSeconds and Milliseconds.
Answer
If you are using C or C++, you will have to include time.hheader file.
#include <time.h>
void my_function() {
// Some code logic of the function here
}
int main() {
// assuming you want to calculate the execution time formy_function
clock_t startTime, endTime;
double totalDuration;
startTime = clock();
my_function();
endTime = clock();
totalDuration = (double(endTime – startTime))/ CLOCKS_PER_SEC //this will give you totalDuration in secs
}
totalDuration is all you
OR
OR