This is a static copy of a profile report

Home

genpath (Calls: 1524, Time: 2.326 s)
Generated 18-Jul-2020 08:10:31 using performance time.
function in file /Applications/MATLAB_R2020a.app/toolbox/matlab/general/genpath.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
hhsave_dis_3OCfunction1
genpathfunction1518
hhsave_VFI_3OCfunction1
hhsave_util_3OCfunction1
OC3function1
optiklfunction1
con_klfunction1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
38
files = dir(d);
15241.759 s75.6%
62
p = [p genpath(fullfile(d,dirn...
15180.313 s13.4%
47
isdir = logical(cat(1,files.is...
15240.088 s3.8%
44
p = [p d pathsep];
15240.061 s2.6%
64
end
45660.021 s0.9%
All other lines  0.084 s3.6%
Totals  2.326 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
fullfilefunction15180.272 s11.7%
pathsepfunction15240.026 s1.1%
genpathfunction15180 s0%
Self time (built-ins, overhead, etc.)  2.028 s87.2%
Totals  2.326 s100% 
Code Analyzer results
Line numberMessage
26Extra comma is unnecessary in IF statement before newline.
62The variable 'p' appears to change size on every loop iteration. Consider preallocating for speed.
Coverage results
Show coverage for parent directory
Total lines in function64
Non-code lines (comments, blank lines)35
Code lines (lines that can run)29
Code lines that did run25
Code lines that did not run4
Coverage (did run/can run)86.21 %
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-2018 The MathWorks, Inc.
  19 
%------------------------------------------------------------------------------
  20 

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

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

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

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

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

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

  0.001 
   1524 
  54
for i=1:length(dirs) 
  0.019 
   4566 
  55
   dirname = dirs(i).name; 
  0.035 
   4566 
  56
   if    ~strcmp( dirname,'.')          && ... 
   3042 
  57
         ~strcmp( dirname,'..')         && ... 
   1518 
  58
         ~strncmp( dirname,classsep,1) && ... 
   1518 
  59
         ~strncmp( dirname,packagesep,1) && ... 
   1518 
  60
         ~strcmp( dirname,'private')    && ... 
   1518 
  61
         ~strcmp( dirname,'resources') 
  0.313 
   1518 
  62
      p = [p genpath(fullfile(d,dirname))]; % recursive calling of this function. 
< 0.001 
   4566 
  63
   end 
  0.021 
   4566 
  64
end 

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