Issue
- I create a new cell in my jupyter notebook.
- I type
%%time
in the first line of my new cell. - I type some codes in the second line.
I run this cell and get some information as follows
CPU times: user 2min 8s, sys: 14.5 s, total: 2min 22s
Wall time: 1min 29s
My question is what does these parameters mean? CPU times, user, sys, total(I think that it means user+total), Wall time
Solution
If we run the code below in a cell:
%%time
from time import sleep
for i in range(3):
print(i, end=' ')
sleep(0.1)
The output is:
0 1 2
CPU times: user 5.69 ms, sys: 118 µs, total: 5.81 ms
Wall time: 304 ms
The wall time means that a clock hanging on a wall outside of the computer would measure 304 ms from the time the code was submitted to the CPU to the time when the process completed.
User time and sys time both refer to time taken by the CPU to actually work on the code. The CPU time dedicated to our code is only a fraction of the wall time as the CPU swaps its attention from our code to other processes that are running on the system.
User time is the amount of CPU time taken outside of the kernel. Sys time is the amount of time taken inside of the kernel. The total CPU time is user time + sys time. The differences between user and sys time is well explained in the post:
What do 'real', 'user' and 'sys' mean in the output of time(1)?
Answered By - Oppy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.