简体   繁体   English

为什么第一次调用Matlab DLL比后续调用花费的时间长?

[英]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.

相关问题 为什么a * b * a在Matlab脚本中使用gpuArray时需要比('*'(a * b)')'更长的时间? - why does a*b*a take longer than (a'*(a*b)')' when using gpuArray in Matlab scripts? 为什么复杂的Matlab gpuArray占用的内存是它应该的两倍? - Why does complex Matlab gpuArray take twice as much memory than it should? 为什么`minmax`需要比连续的'min`和`max`更长的时间? - Why does `minmax` take longer than a consecutive `min` and `max`? Matlab:Simulink如何模拟块计算时间比时钟时间长得多的模型? - Matlab: How does Simulink simulate model with block computation time much longer than clock time period? 为什么Octave的函数调用开销比Matlab和Python大得多? - Why is Octave's function call overhead so much larger than both Matlab's and Python's? 在这个简单的例子中,为什么Matlab看起来比Python慢​​得多 - Why does Matlab seem so much slower than Python in this simple case 返回大量变量的matlab函数需要更长的时间来执行 - does matlab function that returns large number of variables take longer to execute 为什么在python中保存/加载数据比matlab占用更多的空间/时间? - Why does saving/loading data in python take a lot more space/time than matlab? 为什么变量在 Matlab 中不取负值? - Why variable does not take negative value in Matlab? 为什么numpy比数字化示例上的matlab慢得多? - Why is numpy much slower than matlab on a digitize example?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM