- Dec 2023
-
superfastpython.com superfastpython.com
-
Measure Execution Time With time.thread_time()
The
time.thread_time()
reports the time that the current thread has been executing.The time begins or is zero when the current thread is first created.
Return the value (in fractional seconds) of the sum of the system and user CPU time of the current thread.
It is an equivalent value to the
time.process_time()
, except calculated at the scope of the current thread, not the current process.This value is calculated as the sum of the system time and the user time.
thread time = user time + system time
The reported time does not include sleep time.
This means if the thread is blocked by a call to
time.sleep()
or perhaps is suspended by the operating system, then this time is not included in the reported time. This is called a “thread-wide” or “thread-specific” time.
-