Returns the approximate processor time used by the process since the beginning of an implementation-defined era related to the program's execution. To convert result value to seconds divide it by CLOCKS_PER_SEC.
Only the difference between two values returned by different calls to std::clock
is meaningful, as the beginning of the std::clock
era does not have to coincide with the start of the program.
std::clock
time may advance faster or slower than the wall clock, depending on the execution resources given to the program by the operating system. For example, if the CPU is shared by other processes, std::clock
time may advance slower than wall clock. On the other hand, if the current process is multithreaded and more than one execution core is available, std::clock
time may advance faster than wall clock.
Processor time used by the program so far.
Throws nothing.
[edit] NotesOn POSIX-compatible systems, clock_gettime
with clock id CLOCK_PROCESS_CPUTIME_ID offers better resolution.
The value returned by clock()
may wrap around on some implementations. For example, on such an implementation, if std::clock_t is a signed 32-bit integer and CLOCKS_PER_SEC is 1'000'000, it will wrap after about 2147 seconds (about 36 minutes).
This example demonstrates the difference between clock()
time and real time.
Possible output:
CPU time used: 1590.00ms Wall clock time passed: 808.23ms[edit] See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4