1CLOCK(3P)                  POSIX Programmer's Manual                 CLOCK(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       clock — report CPU time used
14

SYNOPSIS

16       #include <time.h>
17
18       clock_t clock(void);
19

DESCRIPTION

21       The functionality described on this reference page is aligned with  the
22       ISO C  standard.  Any  conflict between the requirements described here
23       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2008
24       defers to the ISO C standard.
25
26       The  clock() function shall return the implementation's best approxima‐
27       tion to the processor time used by the process since the  beginning  of
28       an implementation-defined era related only to the process invocation.
29

RETURN VALUE

31       To  determine the time in seconds, the value returned by clock() should
32       be divided by the value of the macro CLOCKS_PER_SEC.  CLOCKS_PER_SEC is
33       defined  to  be one million in <time.h>.  If the processor time used is
34       not available or its value cannot be represented,  the  function  shall
35       return the value (clock_t)−1.
36

ERRORS

38       No errors are defined.
39
40       The following sections are informative.
41

EXAMPLES

43       None.
44

APPLICATION USAGE

46       In  order  to  measure  the  time spent in a program, clock() should be
47       called at the start of the program and its return value subtracted from
48       the  value  returned by subsequent calls. The value returned by clock()
49       is defined for compatibility across systems that have clocks with  dif‐
50       ferent resolutions. The resolution on any particular system need not be
51       to microsecond accuracy.
52
53       The value returned by clock() may wrap around on some  implementations.
54       For  example,  on  a  machine  with 32-bit values for clock_t, it wraps
55       after 2147 seconds or 36 minutes.
56

RATIONALE

58       None.
59

FUTURE DIRECTIONS

61       None.
62

SEE ALSO

64       asctime(), ctime(), difftime(), gmtime(), localtime(), mktime(),  strf‐
65       time(), strptime(), time(), utime()
66
67       The Base Definitions volume of POSIX.1‐2008, <time.h>
68
70       Portions  of  this text are reprinted and reproduced in electronic form
71       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
72       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
73       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
74       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
75       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
76       event of any discrepancy between this version and the original IEEE and
77       The Open Group Standard, the original IEEE and The Open Group  Standard
78       is  the  referee document. The original Standard can be obtained online
79       at http://www.unix.org/online.html .
80
81       Any typographical or formatting errors that appear  in  this  page  are
82       most likely to have been introduced during the conversion of the source
83       files to man page format. To report such errors,  see  https://www.ker
84       nel.org/doc/man-pages/reporting_bugs.html .
85
86
87
88IEEE/The Open Group                  2013                            CLOCK(3P)
Impressum