This is a static copy of a profile report

Home

cell.setdiff>cellsetdiffR2012a (Calls: 10, Time: 0.021 s)
Generated 16-Jul-2020 17:09:35 using performance time.
subfunction in file /Applications/MATLAB_R2020a.app/toolbox/matlab/ops/@cell/setdiff.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
cell.setdifffunction10
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
303
uA = unique(a,order);
100.014 s64.1%
307
uB = unique(b,'R2012a');
100.003 s14.5%
311
d = find(strcmp(sortuAuB(1:end...
100.001 s3.7%
313
indSortuAuB([d;d+1]) = [];    ...
100.001 s3.1%
308
[sortuAuB,indSortuAuB] = sort(...
100.001 s2.5%
All other lines  0.003 s12.3%
Totals  0.021 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
cell.uniquefunction200.016 s73.3%
Self time (built-ins, overhead, etc.)  0.006 s26.7%
Totals  0.021 s100% 
Code Analyzer results
Line numberMessage
Coverage results
Show coverage for parent directory
Total lines in function91
Non-code lines (comments, blank lines)27
Code lines (lines that can run)64
Code lines that did run36
Code lines that did not run28
Coverage (did run/can run)56.25 %
Function listing
time 
Calls 
 line
 247 
function [c,ia] = cellsetdiffR2012a(a,b,options)
 248 
% 'R2012a' flag implementation
 249 

 250 
% flagvals = {'rows' 'sorted' 'stable'};
< 0.001 
     10 
 251
if nargin == 2 
< 0.001 
     10 
 252
    order = 'sorted'; 
 253 
else
 254 
    if (options(1) > 0)
 255 
        warning(message('MATLAB:SETDIFF:RowsFlagIgnored'));
 256 
    end
 257 
    if options(3) > 0
 258 
        order = 'stable';
 259 
    else % if options(2) > 0 || sum(options(2:3)) == 0)
 260 
        order = 'sorted';
 261 
    end
< 0.001 
     10 
 262
end 
 263 

 264 
% Double empties are accepted and converted to empty cellstrs to maintain
 265 
% current behavior.
< 0.001 
     10 
 266
if isequal(class(a),'double') && isequal(a,zeros(0,0)) 
 267 
    a = {};
< 0.001 
     10 
 268
end 
 269 

< 0.001 
     10 
 270
if isequal(class(b),'double') && isequal(b,zeros(0,0)) 
 271 
    b = {};
< 0.001 
     10 
 272
end 
 273 

< 0.001 
     10 
 274
if ischar(a) 
 275 
    if isrow(a)
 276 
        a = {a};  %refrain from using cellstr to preserve trailing spaces
 277 
    else
 278 
        a = cellstr(a);
 279 
    end
< 0.001 
     10 
 280
end 
 281 

< 0.001 
     10 
 282
if ischar(b) 
 283 
    if isrow(b)
 284 
        b = {b};  %refrain from using cellstr to preserve trailing spaces
 285 
    else
 286 
        b = cellstr(b);
 287 
    end
< 0.001 
     10 
 288
end 
 289 

< 0.001 
     10 
 290
if ~iscellstr(a) || ~iscellstr(b) 
 291 
    error(message('MATLAB:SETDIFF:InputClass',class(a),class(b)));
< 0.001 
     10 
 292
end 
 293 

 294 
% Determine if A is a row vector.
< 0.001 
     10 
 295
rowvec = isrow(a); 
 296 

 297 
% Convert a and b to columns.
< 0.001 
     10 
 298
a = a(:); 
< 0.001 
     10 
 299
b = b(:); 
 300 

 301 
% Make sure a and b contain unique elements. Only get indices if needed.
< 0.001 
     10 
 302
if nargout <= 1 
  0.014 
     10 
 303
    uA = unique(a,order); 
 304 
else
 305 
    [uA,ia] = unique(a,order);
< 0.001 
     10 
 306
end 
  0.003 
     10 
 307
uB = unique(b,'R2012a'); 
< 0.001 
     10 
 308
[sortuAuB,indSortuAuB] = sort([uA;uB]); 
 309 

 310 
% d indicates the location of matching entries
< 0.001 
     10 
 311
d = find(strcmp(sortuAuB(1:end-1),sortuAuB(2:end)));     
 312 

< 0.001 
     10 
 313
indSortuAuB([d;d+1]) = [];              % Remove all matching entries 
 314 

< 0.001 
     10 
 315
d = indSortuAuB <= length(uA);          % Values in a that don't match. 
 316 

< 0.001 
     10 
 317
if d == 0                   % Force d to be the correct shape when a is  
 318 
    d = zeros(0,1);         % cell(0,0) and b is nonempty.
< 0.001 
     10 
 319
end 
 320 

 321 
% Find c.
< 0.001 
     10 
 322
if strcmp(order, 'stable')  
 323 
    ndx = sort(indSortuAuB(d));   % Sort indSortuAuB(d) for to maintain 'stable' order.
< 0.001 
     10 
 324
else 
< 0.001 
     10 
 325
    ndx = indSortuAuB(d); 
< 0.001 
     10 
 326
end 
< 0.001 
     10 
 327
c = uA(ndx); 
 328 

 329 
% Find ia.
< 0.001 
     10 
 330
if nargout > 1 
 331 
    ia = ia(ndx);
< 0.001 
     10 
 332
end 
 333 

< 0.001 
     10 
 334
if rowvec 
 335 
    c = c.';
< 0.001 
     10 
 336
end 
< 0.001 
     10 
 337
end 

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