简体   繁体   中英

Using timeit on a cython function

I am trying to time a cython compiled function with timeit using the following syntax:

from offset_back import offset_back

print timeit.timeit(stmt='offset_back(10000,1000,1000)',setup='from main import offset_back',number=1000)

but I keep getting "cannot import name offset_back".

When I print(offset_back(10000,1000,1000))
the function gets called fine, is it possible to use timeit on cython code or do I have to use cProfile?``

Why are you using different syntax in your setup than you used in your example? Why not

print timeit.timeit(stmt='offset_back(10000,1000,1000)',setup='from offset_back import offset_back',number=1000)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM