THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/02/2012 at 13:11, xxxxxxxx wrote:
I've been playing around with the timeit module. And it works fine:
import c4d
import timeit
def main() :
print timeit.timeit('x = 10; y = 100; z = x ** y')
if __name__=='__main__':
main()
But I'm having a problem getting it to work with C4D methods:
import c4d
import timeit
def method1(x,y) :
z = zip(x,y)
z.sort()
return zip(*z)
def main() :
people = ['Jim', 'Pam', 'Micheal', 'Dwight']
ages = [27, 25, 4, 9]
print method1(people, ages)
t = timeit.Timer(setup='from __main__ import method1', stmt='method1()')
print t.timeit() #<-----------Error: Cannot import name method1
if __name__=='__main__':
main()
I think this is the part that is wrong: setup='from __main__ import method1'
Anyone know the correct syntax needed here?
-ScottA