How can I track how long something takes to do with .000 percision? I know how to access time (NULL); but that is only accurate up to seconds and if execution takes .8 seconds it just tells me 0. Time (NULL) returns an integer not a double. Anyone know how to time something? Heres how I have it now.
#include <time.h>
#include <iostream.h>
int main () {
int pretime = time (NULL);
//stuff is done here
int posttime = time (NULL);
cout << "that took " << posttime - pretime << " seconds.";
}
This does work but it is only accurate to the second and not to the 1/1000th of a second like I would like. I need help badly!
#include <time.h>
#include <iostream.h>
int main () {
int pretime = time (NULL);
//stuff is done here
int posttime = time (NULL);
cout << "that took " << posttime - pretime << " seconds.";
}
This does work but it is only accurate to the second and not to the 1/1000th of a second like I would like. I need help badly!