Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.117 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.77; '*S*': 0.00; 'interpreter': 0.05; 'python': 0.08; 'measurement': 0.16; 'subject:timing': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'cheers,': 0.20; 'memory': 0.21; 'header:In-Reply-To:1': 0.22; 'subject:data': 0.25; 'cc:2**0': 0.26; 'function': 0.27; 'compare': 0.28; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'chris': 0.30; 'url:library': 0.31; 'thu,': 0.32; 'there': 0.33; 'algorithms': 0.34; 'latter': 0.34; 'measure': 0.34; 'url:python': 0.35; 'received:209.85.214': 0.36; 'received:google.com': 0.37; 'received:209.85': 0.38; 'could': 0.38; 'some': 0.38; 'url:org': 0.39; "i'd": 0.39; 'received:209': 0.39; 'header:Received:6': 0.61; 'more': 0.61; 'total': 0.61; 'your': 0.61; 'taylor': 0.67; 'time?': 0.73; 'crude': 0.84; 'profiling': 0.84; 'sender:addr:chris': 0.84; 'url:rebertia': 0.84 Received-SPF: pass (google.com: domain of chris@rebertia.com designates 10.205.133.13 as permitted sender) client-ip=10.205.133.13; Authentication-Results: mr.google.com; spf=pass (google.com: domain of chris@rebertia.com designates 10.205.133.13 as permitted sender) smtp.mail=chris@rebertia.com; dkim=pass header.i=chris@rebertia.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=Xif7eTZwfodG9Yy8CBeoP7aowMEv0zLhrJBTW22KBpQ=; b=WYgWmkg1FeZeYZKt4RJnP8kMCtlRRh5HfzR/NN5b6EFl5OXfDEEpycpZ65ft4CgFoP Dv1FvFc2ZdcULvKbLMWSxYMm0Goh8ZNsuM4x4fE4/imcBSW+6EyyQSbJzdj9Tymn+s2D StyzV1L5fYdd5jqPTOQ5CmFtlxAWSQTHX7cpg= MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: References: Date: Thu, 1 Mar 2012 21:44:05 -0800 X-Google-Sender-Auth: NQTTKmFW5WVSHpLoznqafMnxY-A Subject: Re: Spacing and timing for comparing algorithms and data-structures From: Chris Rebert To: Alec Taylor Content-Type: text/plain; charset=UTF-8 X-Gm-Message-State: ALoCoQkVzXaBnl0q0sFZVHXO0n4p3ahH3cZU8xYM4klUqfNKh+1IQiA9CdWfe8LckjN1TvMQNkgp Cc: "comp.lang.python" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1330667047 news.xs4all.nl 6863 [2001:888:2000:d::a6]:32796 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:21120 On Thu, Mar 1, 2012 at 8:55 PM, Alec Taylor wrote: > What would you recommend I use to compare data-structures and > algorithms on space and time? (runtime) For the latter metric, one of the profiling modules: http://docs.python.org/library/debug.html I'd start with timeit and go from there: http://docs.python.org/library/timeit.html For the former metric, you can write your own memory use measurement utility function on top of: http://docs.python.org/library/sys.html#sys.getsizeof Or there is doubtless some Unix tool(s) you could use to get a more crude measure of the total memory used by the Python interpreter process. Cheers, Chris -- http://rebertia.com