[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#286137: glibc-doc: times return vs clock return



Package: glibc-doc
Version: 2.3.2.ds1-19
Severity: normal

In the "Processor Time" node, times() is described with

    The return value is the calling process' CPU time (the same value
    you get from `clock()'.

But I think that's not the case on a Debian system.  For instance,

    #include <stdio.h>
    #include <time.h>
    #include <sys/times.h>
    #include <unistd.h>
    int
    main (void)
    {
      struct tms t;
      printf ("%ld %ld\n", times(&t), clock());
      sleep(1);
      printf ("%ld %ld\n", times(&t), clock());
      return 0;
    }

prints

    430113019 10000
    430113120 10000

times() has increased by 100 for the elapsed 1 second, but clock()
hasn't.

The way the code works corresponds to the posix specs, clock() is cpu
time consumed by the process, but the times() return is real time
(ie. wall clock).


-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i586)
Kernel: Linux 2.6.8-1-386
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

-- no debconf information



Reply to: