Addpath accumulated time lags

8 views (last 30 days)
Jason
Jason on 7 Jun 2011
I am using 2011a on a 64-bit Win7 Pro dual Xeon 6 core machine with 48 GB ram and plenty of disk space.
The problem I am running into is that the addpath and genpath commands over time will slow from 0.5s to over 10s within a script that has been run many times. What would cause this time lag for such a simple function. It almost becomes the main bottleneck in my processing chain. I could recode to avoid using this function, however the use of this function allows for more control over the access of other functions to the working space.
Regards, Jason
  2 Comments
Jason Ross
Jason Ross on 7 Jun 2011
Are the paths you are adding and removing local or on a network share?
Jason
Jason on 7 Jun 2011
Local. They are also destroyed after use.

Sign in to comment.

Answers (2)

Fangjun Jiang
Fangjun Jiang on 7 Jun 2011
10s sounds unreasonable. Did you actually tic toc before and after addpath() and genpath()? What do you mean "over time will slow down"? Is it addpath(genapth()) being called many times in one script, or it is called one time but the script is executed many times? Could you add rehash() after addapth to see if it makes a difference?
  2 Comments
Jason
Jason on 7 Jun 2011
Yes, I used tic/toc. The script is executed many times. I will try the rehash() fnc to see if there is a difference. Thanks
Walter Roberson
Walter Roberson on 7 Jun 2011
Possibly rehash() is being done automatically and that might be taking a fair bit of time.

Sign in to comment.


Jason Ross
Jason Ross on 7 Jun 2011
Have you tried using rmpath when you are done with a given path?
Also, have you reviewed the path as your script progresses? It is possible that the path may be growing significantly if not all the things you think are being removed are actually being removed. Since genpath adds things recursively, it's possible that a growing path with lots of subfolders could affect performance adversely, since you end up running a lot of filesystem operations to traverse the paths.
You might want to also keep Resource Monitor open while you are looking into this, specifically on the disk I/O counter.

Categories

Find more on Search Path in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!