output of evalc
    5 次查看(过去 30 天)
  
       显示 更早的评论
    
Hi, I am trying to load the filenames of 10000+ files (on a network path).
dir & ls seem the obvious commands, but they are both slow (33s for 18k files).
evalc on the other hand takes less than a second. (evalc('dir(...)')) however, the output is in a 1-d char array consisting of all filenames. There are spaces in the filenames as well, so that makes seperating a bit troublesome.
is it possible to get a different output format, or does anyone know a different "solution"?
Thanks! Jaap
PS. It's on a 32bit winXP
采纳的回答
  Daniel Shub
      
      
 2012-1-10
        It seems that
evalc(['dir(', FilePath. ')'])
should go faster than
D = dir(FilePath);
since the evalc method only gets the file names while the direct call gets additional information. On a local filesystem, it probably doesn't matter much, but over a network it could make a big difference.
What about using the system call. On Windows that would be
[~, filenameArray] = system('dir /b');
and on Linux it would be
[~, filenameArray] = system('ls -1');
(note it is a one and not an el). . If you have oddly named or hidden files you may need more parameters.
3 个评论
  Daniel Shub
      
      
 2012-1-10
				I wouldn't extrapolate between what MATLAB does to get the directory information over a network share and how system level calls do it. My guess is it is both OS and mount type dependent. Is this a samba/windows share mount?
更多回答(2 个)
  Jan
      
      
 2012-1-9
        Are you sure that Str = evalc(['dir(', FilePath. ')']) and D = dir(FilePath); have such a large speed difference?! Or did you just call dir at first, such that evalc('dir') can access the cached data?
Please post a copy of the used code.
4 个评论
  Titus Edelhofer
    
 2012-1-10
				Hmm, when scanning the output of evalc you already pointed out the main obstacle: filenames with spaces will give you a hard time (probably making this approach unusable).
  Titus Edelhofer
    
 2012-1-10
        But you could try something similar:
   p = s{2};
  [a,b]=system(['dir /B "' p '"']);
It took about half the time of the dir() call ...
Titus
0 个评论
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



