Re: Strange time() behaviour

new topic     » goto parent     » topic index » view thread      » older message » newer message

I think you are right.
In another computer, with Suse 8 (kernel 2.4.19), I have the right result.
With Ubuntu 6.10 (kernel 2.6.17), I have the *wrong* result.

So I tried compiling the following C program:

#include <stdio.h>
#include <unistd.h>
#include <time.h>

int
main(int argc, char **argv)
{
  long int clk_tck=sysconf(_SC_CLK_TCK);
  printf("CLOCKS_PER_SEC: %li\n", CLOCKS_PER_SEC);
#ifdef CLK_TCK
  printf("CLK_TCK defined: %li\n", CLK_TCK);
#else
  printf("CLK_TCK from sysconf: %li\n", clk_tck);
#endif#ifndef CLK_TCK
#define CLK_TCK CLOCKS_PER_SEC
#endif

}

With Ubuntu 6.10 kernel 2.6.17 it says:

$ ./testclk
CLOCKS_PER_SEC: 1000000
CLK_TCK from sysconf: 100

With Suse 8 kernel 2.4.19:

$ ./testclk
CLOCKS_PER_SEC: 1000000
CLK_TCK defined: 100

So I think the problem is the definition of the macro CLK_TCK.
In fact, in the global.h file, I found the following instructions:

#ifndef CLK_TCK
#define CLK_TCK CLOCKS_PER_SEC
#endif

But, with ubuntu, the value of CLK_TCK is diffent 
from the value of CLOCKS_PER_SEC.

Thanks,

Leonardo

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu