How to implement "time" in Windows ?
In *nix, there the time utility for measuring the execution time of a command
I'm interested in writing my own, so here's my quick attempt :
Code:
#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){
strcpy(command," ");
for (x = 1; x < argc; x++){
strcat(command,argv[x]);
strcat(command," ");
}
start = clock();
system(command);
end = clock();
printf("%f\n",(float)(end-start)/CLOCKS_PER_SEC);
}
return 0;
}
I don't think it perform correctly, probably due to the overhead caused by system().
How can I make it more accurate ? Maybe some Win32 API needed ?