cannot add sys/time.h

Hi, i want to measure the time it takes for a sort.

#include <sys/time.h> does not work. It says couldn't open source file.

Thank you
Yigit
Try this instead

#include <time.h>
<sys/time.h> is a POSIX header, not part of the C/C++ standard library.
If you are using C++ the standard header is <ctime>
The thing is,

ı want to measure the runtime of my sorting and i dont know how else to do it.

1
2
3
4
5
6
7
8
9
10
11
12
#include <sys/time.h>

...
struct timeval tv_begin;
struct timeval tv_end;
int passed_miliseconds;
.....

gettimeofday(&tv_begin,NULL);
         mergeSort(translator1, translator2, size);
		gettimeofday(&tv_end,NULL);
passed_miliseconds=(tv_begin.tv_sec-tv_end.tv_sec)*1000+(tv_begin.tv_usec-tv_end.tv_usec)/1000;
Topic archived. No new replies allowed.