measuring elapsed time
using linux...
I tried numerous suggestions, mostly a version pertaining to :
1 2 3 4 5 6 7 8 9 10 11 12
|
#include <iostream>
#include <ctime>
int main() {
clock_t begin = clock();
while(1){
clock_t end = clock();
double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
std::cout << elapsed_secs << std::endl;
}
}
|
What exactly is this suppose to be, as not one digit measures one second accurately?
The only code that i found that measures seconds accurately is:
1 2 3 4 5 6 7 8 9 10 11 12
|
#include <iostream>
#include <ctime>
int main2(){
clock_t start, end;
time(&start);
while(1){
time(&end);
double dif = difftime(end,start);
std::cout << "seconds: " << dif << std::endl;
}
}
|
but the problem is it measures seconds as whole, as an int. There is no milliseconds, etc.
Thanks
Topic archived. No new replies allowed.