This is a static copy of a profile report

Home

Function details for genpathThis is a static copy of a profile report

Home

genpath (Calls: 290, Time: 0.235 s)
Generated 25-Apr-2020 01:45:52 using performance time.
function in file /Applications/MATLAB_R2018a.app/toolbox/matlab/general/genpath.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
optiklfunction1
genpathfunction289
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
38
files = dir(d);
2900.134 s57.1%
61
p = [p genpath(fullfile(d,dirn...
2890.061 s25.9%
44
p = [p d pathsep];
2900.011 s4.8%
47
isdir = logical(cat(1,files.is...
2900.011 s4.5%
55
dirname = dirs(i).name;
8690.004 s1.5%
All other lines  0.014 s6.1%
Totals  0.235 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
fullfilefunction2890.053 s22.4%
pathsepfunction2900.007 s2.9%
genpathfunction2890 s0%
Self time (built-ins, overhead, etc.)  0.175 s74.7%
Totals  0.235 s100% 
Code Analyzer results
Line numberMessage
26Extra comma is unnecessary in IF statement before newline.
61The variable 'p' appears to change size on every loop iteration. Consider preallocating for speed.
Coverage results
Show coverage for parent directory
Total lines in function63
Non-code lines (comments, blank lines)35
Code lines (lines that can run)28
Code lines that did run22
Code lines that did not run6
Coverage (did run/can run)78.57 %
Function listing
time 
Calls 
 line
   1 
function p = genpath(d)
   2 
%GENPATH Generate recursive toolbox path.
   3 
%   P = GENPATH returns a character vector containing a path name 
   4 
%   that includes all the folders and subfolders below MATLABROOT/toolbox, 
   5 
%   including empty subfolders.
   6 
%
   7 
%   P = GENPATH(FOLDERNAME) returns a character vector containing a path 
   8 
%   name that includes FOLDERNAME and all subfolders of FOLDERNAME, 
   9 
%   including empty subfolders.
  10 
%   
  11 
%   NOTE 1: GENPATH will not exactly recreate the original MATLAB path.
  12 
%
  13 
%   NOTE 2: GENPATH only includes subfolders allowed on the MATLAB
  14 
%   path.
  15 
%
  16 
%   See also PATH, ADDPATH, RMPATH, SAVEPATH.
  17 

  18 
%   Copyright 1984-2017 The MathWorks, Inc.
  19 
%------------------------------------------------------------------------------
  20 

  21 
% String Adoption
< 0.001 
    290 
  22
if nargin > 0 
< 0.001 
    290 
  23
    d = convertStringsToChars(d); 
< 0.001 
    290 
  24
end 
  25 

< 0.001 
    290 
  26
if nargin==0, 
  27 
  p = genpath(fullfile(matlabroot,'toolbox'));
  28 
  if length(p) > 1, p(end) = []; end % Remove trailing pathsep
  29 
  return
  30 
end
  31 

  32 
% initialise variables
< 0.001 
    290 
  33
classsep = '@';  % qualifier for overloaded class directories 
< 0.001 
    290 
  34
packagesep = '+';  % qualifier for overloaded package directories 
< 0.001 
    290 
  35
p = '';           % path to be returned 
  36 

  37 
% Generate path based on given root directory
  0.134 
    290 
  38
files = dir(d); 
< 0.001 
    290 
  39
if isempty(files) 
  40 
  return
  41 
end
  42 

  43 
% Add d to the path even if it is empty.
  0.011 
    290 
  44
p = [p d pathsep]; 
  45 

  46 
% set logical vector for subdirectory entries in d
  0.011 
    290 
  47
isdir = logical(cat(1,files.isdir)); 
  48 
%
  49 
% Recursively descend through directories which are neither
  50 
% private nor "class" directories.
  51 
%
  0.003 
    290 
  52
dirs = files(isdir); % select only directory entries from the current listing 
  53 

< 0.001 
    290 
  54
for i=1:length(dirs) 
  0.004 
    869 
  55
   dirname = dirs(i).name; 
  0.006 
    869 
  56
   if    ~strcmp( dirname,'.')          && ... 
    579 
  57
         ~strcmp( dirname,'..')         && ... 
    289 
  58
         ~strncmp( dirname,classsep,1) && ... 
    289 
  59
         ~strncmp( dirname,packagesep,1) && ... 
    289 
  60
         ~strcmp( dirname,'private') 
  0.061 
    289 
  61
      p = [p genpath(fullfile(d,dirname))]; % recursive calling of this function. 
< 0.001 
    289 
  62
   end 
  0.003 
    869 
  63
end 

Other subfunctions in this file are not included in this listing.