Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81122

Re: Help with an 8th grade science project

References <42700bbc-bd47-439b-aa02-dc58d8d7f513@googlegroups.com> <m4lhvp$qm8$1@ger.gmane.org>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2014-11-20 13:47 -0700
Subject Re: Help with an 8th grade science project
Newsgroups comp.lang.python
Message-ID <mailman.16053.1416516469.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Nov 20, 2014 at 1:13 PM, Dave Angel <davea@davea.name> wrote:
> dave em <daveandem2000@gmail.com> Wrote in message:
>> 1.  In the factorial() function we call the CPU_Percent() function and write the CPU utilization value to a file.
>> -  Is this a correct value or will the CPU utilization below lower because the factorial() function made its calculation and is now just checking the CPU utilization?
>
> I'm not familiar with that package; I just took a quick look at
>  pypi. So I'd have to guess. But since your timing is so huge, I'd
>  guess that you're measuring utilization during a time period that
>  your factorial calculation is paused. In other words you're
>  measuring cpu utilization for the other processes in your
>  system.
>
> Probably someone else will correct me, but I'd guess you need to
>  measure utilization with a separate process.

I'm not familiar with it either, but I would guess that it's probably
just pulling data from /proc/stat. The data is not going to be any
different if pulled from one process versus another. However, the time
that is spent waiting for this data could skew the results if done a
lot, so I suggest doing it only once at the end of the factorial
function rather than on every iteration of the factorial loop.

If you want multiple measurements while the function is running, then
either check it only every X iterations, or run a separate process and
check it every 100 milliseconds or so. The latter is probably
preferable since the time between iterations will depend on the system
and will also get progressively slower for large factorials.

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Help with an 8th grade science project dave em <daveandem2000@gmail.com> - 2014-11-20 09:33 -0800
  Re:Help with an 8th grade science project Dave Angel <davea@davea.name> - 2014-11-20 15:13 -0500
  Re: Help with an 8th grade science project Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-20 13:47 -0700
    Re: Help with an 8th grade science project dave <daveandem2000@gmail.com> - 2014-11-20 13:06 -0800

csiph-web