Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.035 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'latter': 0.09; 'measure': 0.09; 'preferable': 0.09; 'subject:Help': 0.11; 'suggest': 0.14; 'wrote': 0.14; '1:13': 0.16; 'guess.': 0.16; 'iteration': 0.16; 'loop.': 0.16; 'package;': 0.16; 'pulling': 0.16; 'pypi.': 0.16; 'so.': 0.16; 'wrote:': 0.18; 'subject:project': 0.19; 'thu,': 0.19; 'separate': 0.22; 'file.': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'correct': 0.29; 'words': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'another.': 0.31; 'probably': 0.32; 'run': 0.32; 'checking': 0.33; 'guess': 0.33; 'period': 0.33; "i'd": 0.34; 'could': 0.34; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'done': 0.36; 'doing': 0.36; 'nov': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'system.': 0.39; 'either': 0.39; 'dave': 0.60; 'lower': 0.61; 'took': 0.61; "you're": 0.61; 'different': 0.65; 'between': 0.67; '20,': 0.68; 'results': 0.69; '100': 0.79; 'milliseconds': 0.84; 'angel': 0.91; 'lot,': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=vAMmYKM5sfZ86369tUdm/CbsrSPti5I4CJyyBzvbqvM=; b=iU9wMBln40gHJyXhQjp4E4h8K96wp+AwEcBAKXvymTXQIhCaZBr6uXvuMVzGPCzk8P 2mmEKSiWr6mj5PP+/TKZ9qYa0+XQq/UpCXVSojUDI3BNNqqG2lPRXxZEli7NWh9hltHy Mh2st+oRxZhOJs592Y8bisuNbCvRlT89fLGhv7JkDxhjUdcPrpaYksIXsN8hP95jOYQm Z9dYVgnqfbXCd6fpY2hQp7ayIxLc+gRc7Nduw06HaqRttJje2L346TVOZutK2VLIDS0e ii7+RlPQivdN0kJ1NCVHkiDHwDq6k0EbMEYpv31K8cVAVBvliNPSw1J1abFZoY1MKoWH JOuQ== X-Received: by 10.66.159.201 with SMTP id xe9mr458722pab.13.1416516466029; Thu, 20 Nov 2014 12:47:46 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <42700bbc-bd47-439b-aa02-dc58d8d7f513@googlegroups.com> From: Ian Kelly Date: Thu, 20 Nov 2014 13:47:05 -0700 Subject: Re: Help with an 8th grade science project To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416516469 news.xs4all.nl 2976 [2001:888:2000:d::a6]:33498 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81122 On Thu, Nov 20, 2014 at 1:13 PM, Dave Angel wrote: > dave em 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.