timer - How to find how much time has elapsed in C++ using sys/times.h -
i want following:
get t1 run program t2 display t2 - t1
basically i'm trying find out how time program used. have seen several solutions this, 1 1 sys/times.h
used, haven't quite figured out. how can done?
struct timeval timestart,timeend; int error1=gettimeofday(×tart, null); //stuff want measure goes here int error2=gettimeofday(&timeend, null); if(error1 || error2) return -1; //some error occured //this gives result in microseconds. return (timeend.tv_sec - timestart.tv_sec)*1000000.0+(timeend.tv_usec - timestart.tv_usec);
Comments
Post a Comment