alculating elapsed time using clock() returns invalid values on an AMD64 box
Thiago Guzella
thiago.guzella at gmail.com
Mon Oct 4 20:18:13 UTC 2004
Hi there folks,
I have got an AMD64 system running fedora core 2. It's an Athlon64
3500+, on an Asus A8V Deluxe.
I have found something quite intriguing, by running the following code:
------------------
...
clock_t start, end;
start = clock();
// Do some work
end = clock();
elapsed_time = (double) (end - start) / (double) CLOCKS_PER_SEC;
------------------
The calculated time for an specific program i've written is 32.83
seconds, but the time i have calculated by looking at a digital watch
before and after program execution was 125 seconds.
My question is: i am doing something wrong?? Has the clock() way of
measuring elapsed time been deprecated? If so, how should I do it?
uname -a returns: Linux Guzella 2.6.5-1.358 #1 Sat May 8 09:01:26 EDT
2004 x86_64 x86_64 x86_64 GNU/Linux
gcc specs are: Reading specs from
/usr/lib/gcc-lib/x86_64-redhat-linux/3.3.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --disable-libunwind-exceptions --with-system-zlib
--enable-__cxa_atexit --host=x86_64-redhat-linux
Thread model: posix
gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
I'm running the 2.6.5 kernel, as the 2.6.8 won't boot on this
machine (i will be addressing this other issue later...)
Thanks
Thiago Guzella
More information about the fedora-list
mailing list