In UNIX/UNIX-like OSes, you can use the time command.
I'm trying to implement that in Windows, and my first quick attempt this :
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char *argv[]){
clock_t start,end;
int x;
char command[100];
if (argc > 1){
for (int x = 1; x < argc; x++){
strcat(command,argv[x]);
strcat(command," ");
}
start = clock();
system(command);
printf("%f\n",(end-start)/CLOCKS_PER_SEC);
end = clock();
}
return 0;
}
The last output is always "0.0000", which means the execution time is not captured properly.
How can I fix that ? Maybe some Win32 API needed ?