-
July 16th, 2011, 08:59 AM
#1
help with timer
Hello,
i have the code below:
Code:
#include <sys/time.h>
#include <iostream>
using namespace std;
int main(void){
struct timeval start, end;
long differ;
gettimeofday(&start, NULL); //start time.
do_some_work();
differ = end.tv_usec - start.tv_usec; //elapsed time.
cout << "\n\nelapsed time is " << differ;
return 0;
}
i would like to ask the differ is in microseconds or milliseconds ?
Thanks.
-
July 16th, 2011, 09:54 AM
#2
Re: help with timer
The short answer is: neither in microseconds nor milliseconds.
How is the operator -() defined for struct timeval? I guess it is not defined at all!
So, the result of your subtraction is not defined either!
Besides, you did not initialized the end variable, so how do you expect to use it?
Victor Nijegorodov
-
July 17th, 2011, 03:44 AM
#3
Re: help with timer
OK, thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|