time.process_time() function always returns the float value of time in seconds. Return the value (in fractional seconds) of the sum of the system and user CPU time of the current process. It does not include time elapsed during sleep. The reference point of the returned value is undefined, so that only the difference between the results of consecutive calls is valid.
As time module provides various time-related functions. So it is necessary to import the time module otherwise it will through error because of the definition of
time.process_time() is present in
Example: Understand the usage of the process_time().
It always gives the integer value of time in nanoseconds. Similar to process_time() but return time as nanoseconds.This is only the basic difference.
Example: Understand the usage of the
process_time() is very different from
perf_counter() calculates the program time with sleep time and if any interrupt is there but process_counter only calculates the system and the CPU time during the process it not includes the sleep time.
Advantages of process_time() :
1. process_time() provides the system and user CPU time of the current process.
2. We can calculate float and integer both values of time in seconds and nanoseconds.
3. Used whenever there is a need to calculate the time taken by the CPU for the particular process.
- Python - Call function from another function
- Wand function() function in Python
- Returning a function from a function - Python
- wxPython - GetField() function function in wx.StatusBar
- How to write an empty function in Python - pass statement?
- Function Decorators in Python | Set 1 (Introduction)
- Vulnerability in input() function – Python 2.x
- Function Annotations in Python
- Sorted() function in Python
- Ways to sort list of dictionaries by values in Python - Using lambda function
- Python Numbers | choice() function
- Python | askopenfile() function in Tkinter
- Python | Binding function in Tkinter
- floor() and ceil() function Python
- Sum 2D array in Python using map() function
- ord() function in Python
- sum() function in Python
- round() function in Python
- id() function in Python
- vars() function in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.