[英]Why does the first call to a Matlab DLL take much longer than subsequent calls?
I call from my C++ code a DLL that was written in MATLAB. 我从我的C ++代码中调用了一个用MATLAB编写的DLL。 I observe a strange effect: the first call takes much more time that the next calls. 我观察到一个奇怪的效果:第一次通话需要花费更多时间才能进行下一次通话。 It takes 3-4 times more. 它需要3-4倍。 Is it normal? 这是正常的吗? Is it possible to do something with it? 可以用它做点什么吗?
Yes that is normal, the delay comes from starting up the MATLAB Runtime Compiler . 是的,这是正常的,延迟来自启动MATLAB运行时编译器 。 This is what runs the MATLAB code from the dll that you created through MATLAB. 这是从您通过MATLAB创建的dll运行MATLAB代码的原因。 The initial startup cannot be avoided AFAIK, but you can maybe add a dummy call to the DLL when your application begins in order to avoid the "cost" later. 初始启动无法避免AFAIK,但您可以在应用程序启动时向DLL添加虚拟调用,以避免以后的“成本”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.