The following are constants available on UNIX platforms that can be used as the value for the clk_id parameter:
clk_id | clk_id constant | Meaning |
---|---|---|
0 | time.CLOCK_REALTIME | System- wide real-time clock |
1 | time.CLOCK_PROCESS_CPUTIME_ID | High-resolution per-process timer from the CPU |
2 | time.CLOCK_MONOTONIC | It represents monotonic time since some unspecified starting point |
3 | time. CLOCK_THREAD_CPUTIME_ID | Thread-specific CPU-time clock |
4 | time.CLOCK_MONOTONIC_RAW | Similar to time.CLOCK_MONOTONIC, but provides access to a raw hardware-based time that is not subject to NTP adjustments |
Note: time.clock_gettime()
is only available on UNIX-like systems .
Syntax: time.clock_gettime (clk_id)
Parameter:
clk_id : A clk_id constant or an integer value representing clk_id of the clock.Return type: This method returns a float value which represents the time (in seconds) of the specified clock clk_id.
Code # 1: Using the method time.clock_gettime ()
|
|
Exit:
Value of system-wide real-time clock time: 1568587204.9810832 Value of monotonic clock time: 12282.050676627
Link: https://docs.python.org/3/library/time.html#time.clock_gettime
Shop
Latest questions