timeit
From: Duncan Smith (buzzard_at_urubu.freeserve.co.uk)
Date: 01/31/04
- Next message: Jp Calderone: "Re: NEWLINE character problem"
- Previous message: Jp Calderone: "Re: Tcp/ip programs in python"
- Next in thread: Rich Krauter: "Re: timeit"
- Reply: Rich Krauter: "Re: timeit"
- Maybe reply: Robert Brewer: "RE: timeit"
- Reply: Skip Montanaro: "Re: timeit"
- Maybe reply: Skip Montanaro: "Re: timeit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 31 Jan 2004 04:21:45 -0000
This is possibly a stupid question, but I need to get this working quickly,
and I guess I'm just too tired / pressured to see what I'm doing wrong.
Clearly (from the output below) I can't pass the statement to an instance of
timeit.Timer, but I can execute it using exec(). Any idea what I need to do
to get this timed (using timeit). Cheers.
>>> import SDC_table
>>> import subtract
>>> import timeit
>>> t = SDC_table.RandomTable(1, 12, (2,3,4))
>>> s = """\
p = subtract.p_risk(t.values, 10)
"""
>>> tim = timeit.Timer(stmt=s)
>>> tim.timeit(10)
Traceback (most recent call last):
File "<pyshell#119>", line 1, in -toplevel-
tim.timeit(10)
File "C:\Python23\lib\timeit.py", line 158, in timeit
return self.inner(it, self.timer)
File "<timeit-src>", line 6, in inner
NameError: global name 'subtract' is not defined
# yet
>>> exec(s)
>>> p
0.242621453769059
- Next message: Jp Calderone: "Re: NEWLINE character problem"
- Previous message: Jp Calderone: "Re: Tcp/ip programs in python"
- Next in thread: Rich Krauter: "Re: timeit"
- Reply: Rich Krauter: "Re: timeit"
- Maybe reply: Robert Brewer: "RE: timeit"
- Reply: Skip Montanaro: "Re: timeit"
- Maybe reply: Skip Montanaro: "Re: timeit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|