slow perfomance if network directories are in path

8 Ansichten (letzte 30 Tage)
Björn Rumberg
Björn Rumberg am 26 Okt. 2018
Beantwortet: Mathias am 16 Apr. 2021
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 Kommentare
Bruno Luong
Bruno Luong am 26 Okt. 2018
Bearbeitet: Bruno Luong am 26 Okt. 2018
" 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 am 26 Okt. 2018
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Mathias
Mathias am 16 Apr. 2021
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

Kategorien

Mehr zu Search Path finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by