This is a static copy of a profile report

Home

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

Home

path (Calls: 3, Time: 0.277 s)
Generated 01-May-2020 20:23:05 using performance time.
function in file /Applications/MATLAB_R2018a.app/toolbox/matlab/general/path.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
addpathfunction3
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
109
matlabpath([cPath1{:} cPath2{:...
30.198 s71.4%
74
cPath2 = parsedirs(path2);
30.027 s9.8%
99
pmatch = pmatch | strcmp(cPath...
9570.017 s6.1%
73
cPath1 = parsedirs(path1);
30.014 s5.1%
71
if ~isempty(path2Cased) &&...
30.013 s4.8%
All other lines  0.008 s2.8%
Totals  0.277 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
general/private/parsedirsfunction60.040 s14.6%
strcatfunction30.012 s4.4%
path>isValidInputsubfunction60.000 s0.2%
Self time (built-ins, overhead, etc.)  0.224 s80.8%
Totals  0.277 s100% 
Code Analyzer results
Line numberMessage
67Consider using newline, semicolon, or comma before this statement for readability.
Coverage results
Show coverage for parent directory
Total lines in function114
Non-code lines (comments, blank lines)47
Code lines (lines that can run)67
Code lines that did run41
Code lines that did not run26
Coverage (did run/can run)61.19 %
Function listing
time 
Calls 
 line
   1 
function p = path(path1,path2)
   2 
%PATH Get/set search path.
   3 
%   PATH, by itself, prettyprints MATLAB's current search path. The initial
   4 
%   search path list is set by PATHDEF, and is perhaps individualized by
   5 
%   STARTUP.
   6 
%
   7 
%   P = PATH returns a character vector containing the path in P. PATH(P)
   8 
%   changes the path to P.
   9 
%
  10 
%   PATH(P1,P2) changes the path to the concatenation of the two search 
  11 
%   paths P1 and P2.  Thus PATH(PATH,P) appends the folder P to the
  12 
%   current path and PATH(P,PATH) prepends the folder P.  If P is already
  13 
%   on the path, then PATH(PATH,P) moves P to the end of the path,
  14 
%   and similarly, PATH(P,PATH) moves P to the beginning of the path.
  15 
%
  16 
%   For example, the following statements add another folder to MATLAB's
  17 
%   search path on various operating systems:
  18 
%
  19 
%     Unix:     path(path,'/home/myfriend/goodstuff')
  20 
%     Windows:  path(path,'c:\tools\goodstuff')
  21 
%
  22 
%   See also WHAT, CD, DIR, ADDPATH, RMPATH, GENPATH, PATHTOOL, SAVEPATH, REHASH.
  23 

  24 
%   Copyright 1984-2017 The MathWorks, Inc.
  25 

< 0.001 
      3 
  26
if nargin == 0  % Pretty-print 
  27 
    if nargout == 0
  28 
        matlabpath
  29 
    end
< 0.001 
      3 
  30
elseif nargin == 1 
  31 
    if ~isValidInput(path1)
  32 
        error(message('MATLAB:string:MustBeStringScalarOrCharacterVector'))
  33 
    end
  34 
    matlabpath(path1) % matlabpath will check and process path1
< 0.001 
      3 
  35
elseif nargin == 2 
< 0.001 
      3 
  36
    if ~isValidInput(path2) || ~isValidInput(path1) 
  37 
        error(message('MATLAB:string:MustBeStringScalarOrCharacterVector'))
  38 
    end
  39 

  40 
    % If path1 is contained in path2 or vice versa, don't add it
  0.003 
      3 
  41
    pp = matlabpath; 
  42 
    % Windows is case-insensitive
  43 
    % Use "Cased" variables for comparisons,
  44 
    %   but do real work on path1 and path2
  45 
	% Define FILESEP and PATHSEP, since these are not built-in
  46 
	% and PATH might be called with an empty MATLAB path
  0.001 
      3 
  47
    if strncmp(computer,'PC',2) 
  48 
        ps = ';';
  49 
        path1 = strrep(path1,'/','\');
  50 
        path2 = strrep(path2,'/','\');
  51 
        path1Cased  = lower(path1);
  52 
        path2Cased  = lower(path2);
  53 
        ppCased = lower(pp);
< 0.001 
      3 
  54
    else 
< 0.001 
      3 
  55
        ps = ':'; 
< 0.001 
      3 
  56
        path1Cased = path1; 
< 0.001 
      3 
  57
        path2Cased = path2; 
< 0.001 
      3 
  58
        ppCased = pp; 
< 0.001 
      3 
  59
    end 
  60 

< 0.001 
      3 
  61
    if isempty(path1Cased) 
  62 
        if ~strcmp(ppCased,path2Cased), matlabpath(path2), end
< 0.001 
      3 
  63
    elseif isempty(path2Cased) 
  64 
        if ~strcmp(ppCased,path1Cased), matlabpath(path1), end
< 0.001 
      3 
  65
    else 
  66 
        % Check for special cases path(path1,path) or path(path,path2)
< 0.001 
      3 
  67
        if strcmp(ppCased,path1Cased), append = 1; else append = 0; end 
  68 

  69 
        % Add path separator to path1 and path2
< 0.001 
      3 
  70
        if ~isempty(path1Cased) && path1Cased(end)~=ps, path1 = strcat(path1,ps); end 
  0.013 
      3 
  71
        if ~isempty(path2Cased) && path2Cased(end)~=ps, path2 = strcat(path2,ps); end 
  72 

  0.014 
      3 
  73
        cPath1 = parsedirs(path1); 
  0.027 
      3 
  74
        cPath2 = parsedirs(path2); 
  75 

  76 
        % Use "Cased" variables for comparisons,
  77 
        %   but do real work on cPath1 and cPath2
< 0.001 
      3 
  78
        if strncmp(computer,'PC',2) 
  79 
            cPath1Cased  = lower(cPath1);
  80 
            cPath2Cased  = lower(cPath2);
< 0.001 
      3 
  81
        else 
< 0.001 
      3 
  82
            cPath1Cased = cPath1; 
< 0.001 
      3 
  83
            cPath2Cased = cPath2; 
< 0.001 
      3 
  84
        end 
  85 

  86 
        % Loop through path to see if we're adding existing paths
  87 
        % If so, move them to the beginning or end as specified
  88 
        % On Windows, search without case, but use actual inputs when
  89 
        % calling MATLABPATH to preserve case
< 0.001 
      3 
  90
        if append 
  91 
            pmatch = false(size(cPath1));
  92 
            for n=1:length(cPath2Cased)
  93 
                pmatch = pmatch | strcmp(cPath2Cased{n},cPath1Cased);
  94 
            end
  95 
            cPath1(pmatch) = [];
< 0.001 
      3 
  96
        else 
< 0.001 
      3 
  97
            pmatch = false(size(cPath2)); 
< 0.001 
      3 
  98
            for n=1:length(cPath1Cased) 
  0.017 
    957 
  99
                pmatch = pmatch | strcmp(cPath1Cased{n},cPath2Cased); 
< 0.001 
    957 
 100
            end 
< 0.001 
      3 
 101
            cPath2(pmatch) = []; 
< 0.001 
      3 
 102
        end 
 103 

< 0.001 
      3 
 104
        if isempty(cPath2) 
 105 
            matlabpath(path1);
< 0.001 
      3 
 106
        elseif isempty(cPath1) 
 107 
            matlabpath(path2);
< 0.001 
      3 
 108
        else 
  0.198 
      3 
 109
            matlabpath([cPath1{:} cPath2{:}]); 
< 0.001 
      3 
 110
        end 
< 0.001 
      3 
 111
    end 
< 0.001 
      3 
 112
end 
 113 

< 0.001 
      3 
 114
if nargout==1, p = matlabpath; end 

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