[Python-talk] Using timeit

bruce.labitt at autoliv.com bruce.labitt at autoliv.com
Wed Oct 14 14:05:51 EDT 2009


Is it possible to use timeit in running code?  This is what I'm trying to 
do.

import timeit

s = """\
cmd = 4
fftdatareal = pack( fmt, cmd, *realX )
cmd = 5
fftdataimag = pack( fmt, cmd, *imagX )
"""
t = timeit.Timer(stmt=s)
print "%.2f sec" % t.timeit(number=1)

This give a NameError: global name 'pack' is not defined

How does one fix the name error? 
Will fftdatareal and fftdataimag be populated using this construction?
Will the stdout have the time in seconds for the packing?


Bruce Labitt
Autoliv Electronics
1011B Pawtucket Blvd, PO Box 1858
Lowell, MA  01853

Email: bruce.labitt at autoliv.com. 
Tel:  (978) 674-6526
Fax: (978) 674-6581 

******************************
Neither the footer nor anything else in this E-mail is intended to or constitutes an <br>electronic signature and/or legally binding agreement in the absence of an <br>express statement or Autoliv policy and/or procedure to the contrary.<br>This E-mail and any attachments hereto are Autoliv property and may contain legally <br>privileged, confidential and/or proprietary information.<br>The recipient of this E-mail is prohibited from distributing, copying, forwarding or in any way <br>disseminating any material contained within this E-mail without prior written <br>permission from the author. If you receive this E-mail in error, please <br>immediately notify the author and delete this E-mail.  Autoliv disclaims all <br>responsibility and liability for the consequences of any person who fails to <br>abide by the terms herein. <br>
******************************


More information about the Python-talk mailing list