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: 1, Time: 0.093 s)
Generated 25-Apr-2020 01:45:54 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
addpathfunction1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
109
matlabpath([cPath1{:} cPath2{:...
10.056 s60.2%
74
cPath2 = parsedirs(path2);
10.011 s11.7%
71
if ~isempty(path2Cased) &&...
10.011 s11.4%
73
cPath1 = parsedirs(path1);
10.006 s6.6%
99
pmatch = pmatch | strcmp(cPath...
2900.005 s5.1%
All other lines  0.005 s5.1%
Totals  0.093 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
general/private/parsedirsfunction20.016 s17.3%
strcatfunction10.010 s10.6%
path>isValidInputsubfunction20.000 s0.5%
Self time (built-ins, overhead, etc.)  0.067 s71.6%
Totals  0.093 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 
      1 
  26
if nargin == 0  % Pretty-print 
  27 
    if nargout == 0
  28 
        matlabpath
  29 
    end
< 0.001 
      1 
  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 
      1 
  35
elseif nargin == 2 
< 0.001 
      1 
  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.001 
      1 
  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 
      1 
  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 
      1 
  54
    else 
< 0.001 
      1 
  55
        ps = ':'; 
< 0.001 
      1 
  56
        path1Cased = path1; 
< 0.001 
      1 
  57
        path2Cased = path2; 
< 0.001 
      1 
  58
        ppCased = pp; 
< 0.001 
      1 
  59
    end 
  60 

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

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

  0.006 
      1 
  73
        cPath1 = parsedirs(path1); 
  0.011 
      1 
  74
        cPath2 = parsedirs(path2); 
  75 

  76 
        % Use "Cased" variables for comparisons,
  77 
        %   but do real work on cPath1 and cPath2
< 0.001 
      1 
  78
        if strncmp(computer,'PC',2) 
  79 
            cPath1Cased  = lower(cPath1);
  80 
            cPath2Cased  = lower(cPath2);
< 0.001 
      1 
  81
        else 
< 0.001 
      1 
  82
            cPath1Cased = cPath1; 
< 0.001 
      1 
  83
            cPath2Cased = cPath2; 
< 0.001 
      1 
  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 
      1 
  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 
      1 
  96
        else 
< 0.001 
      1 
  97
            pmatch = false(size(cPath2)); 
< 0.001 
      1 
  98
            for n=1:length(cPath1Cased) 
  0.005 
    290 
  99
                pmatch = pmatch | strcmp(cPath1Cased{n},cPath2Cased); 
< 0.001 
    290 
 100
            end 
< 0.001 
      1 
 101
            cPath2(pmatch) = []; 
< 0.001 
      1 
 102
        end 
 103 

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

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

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