[Tutor] I can't believe this needs to be this complex

Dick Moores rdm at rcblue.com
Sun Aug 3 06:11:41 CEST 2008


At 10:08 AM 8/2/2008, Alan Gauld wrote:
>"Dick Moores" <rdm at rcblue.com> wrote
>
>>BTW Kent, I'm going to take this opportunity to ask you about 
>>"System" in the IPython timing results. It's always zero for the 
>>code I time. What's an example of code that would have System be 
>>greater than zero? And what's the distinction between User and 
>>System? (I'm using Win XP, if that's relevant.)
>
>In timing user time is time that the CPU spends executing user
>code - your program. System time is time the CPU spends doing
>OS things.
>
>If your code had a blocking call that waited for input on a port say,
>then the OS might be doing other stuff in the background while
>your code waited. This would show as system time.
>In some OR even time spent reading files from disk is
>counted as system time because your code is executing
>low level OS functions.
>
>Try timing a function that does nothing but read a large file.
>See if there is any system time showing up.

Well, here's one that reads in the text of Dickens' _Little Dorrit_ 
and returns the word count:

In [11]: run -t -N10 timing_test_little_dorrit.py
339832
339832
339832
339832
339832
339832
339832
339832
339832
339832

IPython CPU timings (estimated):
Total runs performed: 10
   Times :      Total       Per run
   User  : 5.94446752311 s, 0.594446752311 s.
   System:        0.0 s,        0.0 s.

>Or time a GUI
>app that waits for user input...

This one is a Gui that has an Exit button. I called it and then hit the button:

In [4]: run -t ToolkitV15.py

IPython CPU timings (estimated):
   User  : 10.5294301371 s.
   System:        0.0 s.

So no non-zero System time yet. But thanks for your explanation.

Dick




More information about the Tutor mailing list