os
moduleThe os
module in Python provides functions that help in interacting with the underlying operating system.
times()
methodThe times()
method returns the current global process times. The current global process timings are represented as a tuple-like object with five named properties that are returned by this function. These five attributes are as follows:
user
: This attribute represents the user time.system
: This attribute represents the system time.children_user
: This attribute represents the user time of all the child processes.children_system
: This attribute represents the system time of all the child processes.elapsed
: This attribute represents the elapsed real time since a fixed point in the past.os.times()
This method has no parameters.
import osdiff_times = os.times()print("User time - ", diff_times.user)print("System time - ", diff_times.system)print("Children User time - ", diff_times.children_user)print("Children System time - ", diff_times.children_system)print("Elapsed time - ", diff_times.elapsed)
os
module is imported.os.times()
method.user
property of the diff_times
object. The user time can also be obtained using diff_times[0]
.system
property of the diff_times
object. The system time can also be obtained using diff_times[1]
.children_user
property of the diff_times
object. The children_user
time can also be obtained using diff_times[2]
.children_system
property of the diff_times
object. The children_system
time can also be obtained using diff_times[3]
.elapsed
property of the diff_times
object. The elapsed time can also be obtained using diff_times[4]
.