This is a static copy of a profile report

Home

tabular.disp>alignTabularContents (Calls: 8, Time: 0.013 s)
Generated 16-Jul-2020 17:09:57 using performance time.
subfunction in file /Applications/MATLAB_R2020a.app/toolbox/matlab/datatypes/tabular/@tabular/disp.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
tabular.dispfunction8
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
359
tagged = containsRegexp(s,'<...
80.003 s24.5%
376
s(ppI >= r,c) = s(ppI >=...
800.002 s17.0%
364
varLengthM(tagged) = vectorize...
80.002 s12.9%
362
tagged(idx) = tagged(idx) || a...
8000.001 s10.5%
365
for c=1:cols
80.001 s7.0%
All other lines  0.004 s28.2%
Totals  0.013 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
tabular.disp>containsRegexpsubfunction80.003 s22.2%
tabular.disp>vectorizedWrappedLengthsubfunction80.001 s6.8%
Self time (built-ins, overhead, etc.)  0.010 s71.0%
Totals  0.013 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function54
Non-code lines (comments, blank lines)28
Code lines (lines that can run)26
Code lines that did run24
Code lines that did not run2
Coverage (did run/can run)92.31 %
Function listing
time 
Calls 
 line
 326 
function [s, maxVarLen, colWidth] = alignTabularContents(s, colWidth)
 327 
% When the variables in a table are strings or chars, there is a
 328 
% possibility for them to be misaligned. For instance, strings
 329 
% containing hyperlinks will show up on the command window as
 330 
% possibly a different character width than what strlength()
 331 
% returns. Same for <strong> text. International characters also
 332 
% pose this problem, since the widths of Unicode characters cannot
 333 
% be guaranteed to be the same, usually causing strings containing
 334 
% international characters to be wider than ASCII text with the
 335 
% same number of characters.
 336 

 337 
% The purpose of alignTabularContents is to check for these
 338 
% potential cases of misalignment and adjust the strings properly
 339 
% so they are as close to even as possible. wrappedLength() is used
 340 
% to accurately obtain the display width of each line of text. For
 341 
% the case of international characters, it is impossible to line
 342 
% them up exactly due to them being non-integral character lengths.
 343 
% Thus, the remainder is tracked to ensure they are aligned within
 344 
% 1 character of other ASCII lines.
 345 

 346 
% alignTabularContents is used to align table variables that are
 347 
% nx1 strings or multi-column table variables to ensure that each
 348 
% sub-column of a table variable is aligned properly, before that
 349 
% variable is aligned with other variables in the table.
 350 

< 0.001 
      8 
 351
if nargin < 2 
 352 
    [rows, cols] = size(s);
 353 
    colWidth = zeros(rows,1);
< 0.001 
      8 
 354
else 
 355 
    %rows = size(s,1);
< 0.001 
      8 
 356
    cols = 1; 
< 0.001 
      8 
 357
end 
 358 

  0.003 
      8 
 359
tagged = containsRegexp(s,'<a\s+href\s*=|<strong>'); 
< 0.001 
      8 
 360
varLengthM = strlength(s); 
< 0.001 
      8 
 361
for idx = 1:numel(s) 
  0.001 
    800 
 362
    tagged(idx) = tagged(idx) || any(s{idx} > char(128)); 
< 0.001 
    800 
 363
end 
  0.002 
      8 
 364
varLengthM(tagged) = vectorizedWrappedLength(s(tagged)); 
< 0.001 
      8 
 365
for c=1:cols 
< 0.001 
      8 
 366
    varLength = varLengthM(:,c); 
< 0.001 
      8 
 367
    maxVarLen = max(ceil(varLength)); 
< 0.001 
      8 
 368
    postPadLen = maxVarLen - varLength; 
< 0.001 
      8 
 369
    colWidth = colWidth + (postPadLen - floor(postPadLen)); 
< 0.001 
      8 
 370
    tooLong = colWidth > 1; 
< 0.001 
      8 
 371
    colWidth(tooLong) = colWidth(tooLong) - 1; 
< 0.001 
      8 
 372
    postPadLen(tooLong) = postPadLen(tooLong) +1; 
< 0.001 
      8 
 373
    ppI = floor(postPadLen); 
< 0.001 
      8 
 374
    for r = 1:max(ppI) 
 375 
        % add the spaces in place to improve performance
  0.002 
     80 
 376
        s(ppI >= r,c) = s(ppI >= r,c) + " "; 
< 0.001 
     80 
 377
    end 
< 0.001 
      8 
 378
end 
< 0.001 
      8 
 379
end 

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