Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!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.056 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'iit': 0.09; 'measure': 0.09; 'run,': 0.09; 'runtime': 0.09; 'subject:Help': 0.11; 'python': 0.11; 'mostly': 0.14; 'cached': 0.16; 'measurement': 0.16; 'subject:run': 0.16; 'subject:python': 0.16; 'student': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'trying': 0.19; 'dependent': 0.19; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'ideal': 0.29; 'message-id:@mail.gmail.com': 0.30; 'gives': 0.31; 'constant': 0.31; 'run': 0.32; 'running': 0.33; 'subject:time': 0.33; 'received:google.com': 0.35; 'disk': 0.36; 'ram': 0.36; 'subject:regarding': 0.36; 'doing': 0.36; 'hi,': 0.36; 'minimum': 0.38; 'conditions.': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'read': 0.60; 'hardware': 0.61; 'times': 0.62; 'happen': 0.63; 'different': 0.65; 'taking': 0.65; 'occur': 0.65; '20,': 0.68; 'results': 0.69; 'request.': 0.70; 'sector': 0.72; '2015': 0.84; 'cylinder': 0.84; 'factors': 0.97 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=63qvVlbSbF3l7PdrN/ebcNk5Vlo4Yn3kCvzacbw99PM=; b=lHfjecSAnVagVgQ6SUcY1E2MyBCEi2cyd1Trj/nCA34qYWyhAzcufY9Yc0VdCh0PxP /gi4p8Sdxv54zi/uSozhwqZQz0wDYmpWn4z0nzzNV5XQyIKynS3RLTYpcCZVtvm7OqQw vyFSGWGlUfTZTZI4WAwKvcokRbioWj4FATCCYBg0Ky7n6Zu2BBNWKAvdnExB0IAapmc/ Ao6w/Y0swnMYky4aBYjkZc6Hne4kYyYyrQO4EZYigPp/HcNQ4KZX91BDar3nW8hDzI9H oZnrtwOYfXYPAcuw5cItn9wXZaqGVIYOWyn1LMWMl6PLdAaPucDQ4I7yH6WJqxVAHqp+ FuLw== X-Received: by 10.43.65.19 with SMTP id xk19mr47921600icb.20.1432135446133; Wed, 20 May 2015 08:24:06 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Wed, 20 May 2015 09:23:25 -0600 Subject: Re: Help regarding python run time To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1432135454 news.xs4all.nl 2852 [2001:888:2000:d::a6]:38552 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90958 On Wed, May 20, 2015 at 7:02 AM, AKHIL RANA wrote: > Hi, > > I am student at IIT Kanpur and working on a Opencv based Python project. I > am working on program development which takes less time to execute. For that > i have tested my small program hello word on python to now the time taken by > this program. I had run many time. and every time it run it gives me a > different run time. > > Can we some how make the program to run at constant time so that we can work > on how to reduce the timing ? Not practically. The exact run time is dependent on a lot of factors that are mostly out of your control: what other programs are running, what they're doing and what resources they're using at that moment; what hardware interrupts occur while your program is running; is data to be read from disk cached or not; is data to be loaded from RAM cached or not; if the disk is mechanical, what cylinder and sector does the read head happen to be at when it gets a read request. Instead of trying to measure an exact time over one run, you will get better results by running the program several times and then taking the minimum measurement as representative of the program's runtime under ideal conditions.