logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

clock.3p (3539B)


  1. '\" et
  2. .TH CLOCK "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. clock
  12. \(em report CPU time used
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <time.h>
  17. .P
  18. clock_t clock(void);
  19. .fi
  20. .SH DESCRIPTION
  21. The functionality described on this reference page is aligned with the
  22. ISO\ C standard. Any conflict between the requirements described here and the
  23. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  24. .P
  25. The
  26. \fIclock\fR()
  27. function shall return the implementation's best approximation to the
  28. processor time used by the process since the beginning of an
  29. implementation-defined era related only to the process invocation.
  30. .SH "RETURN VALUE"
  31. To determine the time in seconds, the value returned by
  32. \fIclock\fR()
  33. should be divided by the value of the macro CLOCKS_PER_SEC.
  34. CLOCKS_PER_SEC is defined to be one million in
  35. .IR <time.h> .
  36. If the processor time used is not available or its value cannot be
  37. represented, the function shall return the value (\c
  38. .BR clock_t )\-1.
  39. .SH ERRORS
  40. No errors are defined.
  41. .LP
  42. .IR "The following sections are informative."
  43. .SH EXAMPLES
  44. None.
  45. .SH "APPLICATION USAGE"
  46. In programming environments where
  47. .BR clock_t
  48. is a 32-bit integer type and CLOCKS_PER_SEC is one million,
  49. \fIclock\fR()
  50. will start failing in less than 36 minutes of processor time for
  51. signed
  52. .BR clock_t ,
  53. or 72 minutes for unsigned
  54. .BR clock_t .
  55. Applications intended to be portable to such environments should use
  56. \fItimes\fR()
  57. instead (or
  58. \fIclock_gettime\fR()
  59. with CLOCK_PROCESS_CPUTIME_ID, if supported).
  60. .P
  61. In order to measure the time spent in a program,
  62. \fIclock\fR()
  63. should be called at the start of the program and its return value
  64. subtracted from the value returned by subsequent calls. The value
  65. returned by
  66. \fIclock\fR()
  67. is defined for compatibility across systems that have clocks with
  68. different resolutions. The resolution on any particular system need
  69. not be to microsecond accuracy.
  70. .SH RATIONALE
  71. None.
  72. .SH "FUTURE DIRECTIONS"
  73. None.
  74. .SH "SEE ALSO"
  75. .IR "\fIasctime\fR\^(\|)",
  76. .IR "\fIclock_getres\fR\^(\|)",
  77. .IR "\fIctime\fR\^(\|)",
  78. .IR "\fIdifftime\fR\^(\|)",
  79. .IR "\fIgmtime\fR\^(\|)",
  80. .IR "\fIlocaltime\fR\^(\|)",
  81. .IR "\fImktime\fR\^(\|)",
  82. .IR "\fIstrftime\fR\^(\|)",
  83. .IR "\fIstrptime\fR\^(\|)",
  84. .IR "\fItime\fR\^(\|)",
  85. .IR "\fItimes\fR\^(\|)",
  86. .IR "\fIutime\fR\^(\|)"
  87. .P
  88. The Base Definitions volume of POSIX.1\(hy2017,
  89. .IR "\fB<time.h>\fP"
  90. .\"
  91. .SH COPYRIGHT
  92. Portions of this text are reprinted and reproduced in electronic form
  93. from IEEE Std 1003.1-2017, Standard for Information Technology
  94. -- Portable Operating System Interface (POSIX), The Open Group Base
  95. Specifications Issue 7, 2018 Edition,
  96. Copyright (C) 2018 by the Institute of
  97. Electrical and Electronics Engineers, Inc and The Open Group.
  98. In the event of any discrepancy between this version and the original IEEE and
  99. The Open Group Standard, the original IEEE and The Open Group Standard
  100. is the referee document. The original Standard can be obtained online at
  101. http://www.opengroup.org/unix/online.html .
  102. .PP
  103. Any typographical or formatting errors that appear
  104. in this page are most likely
  105. to have been introduced during the conversion of the source files to
  106. man page format. To report such errors, see
  107. https://www.kernel.org/doc/man-pages/reporting_bugs.html .