Why is matlab.engine for python so slow?
I am calling MATLAB functions from Python via MATLAB Engine for Python
, but it is not efficient.
A pure Matlab script works in 30ms
, and a python script in 5.xs
.
Is there a reason? What should I do?
Python code:
import matlab.engine,time
start = time.clock()
eng = matlab.engine.start_matlab()
eng.forward
elapsed = (time.clock() - start)
print("Time used:",elapsed)
Python script reslut:
('Time used:', 4.879795798557371)
Matlab runtime:
函数名称 | 调用总时间 | 自用时间
forward | 0.029 s | 0.015 s
+3
source to share
1 answer