slow perfomance if network directories are in path

8 次查看(过去 30 天)
I add several network directories to the path during startup.
If network is not very very good, Matlab performance is dramatically reduced. Each input in the command window takes several seconds. Even if it is just a simple calculation like 1+1. I got the feeling that Matlab is searching the whole path before executing the input. This takes some time due to bad network performance.
Is there any option to increase performance? Such as caching all m files in the path?
  4 个评论
Bruno Luong
Bruno Luong 2018-10-26
编辑:Bruno Luong 2018-10-26
" Can I tell manually when to refresh cache and when not to "
Yes REHASH for the first part, no for the second part of your question AFAIK.
Put your commands in function (and not in script) then it caches at the beginning once.
If you use script then there is no way to stop it beside removing the path. That's how it supposes to work.
Walter Roberson
Walter Roberson 2018-10-26
I suspect that the basic problem is that MATLAB automatically checks directories on the path for changed files when it gets to the command prompt. The standard toolboxes are exempt as those are not expected to change.
Be sure to avoid having a network drive open in the directory window.

请先登录,再进行评论。

回答(1 个)

Mathias
Mathias 2021-4-16
I don't have network pathes in path but tried to check network pathes for existence (i.e. \\device\folders). If the device is not existent it takes around 45sec to check this. After some readings i found a fast solution to get this information. This can be used to deselect invalid pathes for search.
% check for existence of devices
devexists = true;
dev = regexp(pathname, '(?<=^\\\\)[^\\]+(?=\\)', 'ignorecase', 'once', 'match'); % device name
if any(dev)
[~, txt] = dos(['nslookup "' dev '"']);
if any(strfind(txt, 'Non-existent domain'))
devexists = false;
end
end

类别

Help CenterFile Exchange 中查找有关 Search Path 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by