简体   繁体   English

在cython函数上使用timeit

[英]Using timeit on a cython function

I am trying to time a cython compiled function with timeit using the following syntax: 我正在尝试使用以下语法使用timeit对cython编译函数进行计时:

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". 但我不断收到“无法导入名称offset_back”。

When I print(offset_back(10000,1000,1000)) 当我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?`` 该函数被称为罚款,是否可以在cython代码上使用timeit还是我必须使用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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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