partialMatchString (Calls: 20, Time: 0.003 s)
Generated 16-Jul-2020 17:09:34 using performance time.
function in file /Applications/MATLAB_R2020a.app/toolbox/matlab/ops/+matlab/+internal/+math/partialMatchString.m
Copy to new window for comparing multiple runs
Function Name | Function Type | Calls |
cell.unique | function | 20 |
Line Number | Code | Calls | Total Time | % Time | Time Plot |
18 | tf = strncmpi(str, options, ma... | 20 | 0.002 s | 64.7% | |
15 | if ~((ischar(str) && i... | 20 | 0.000 s | 9.5% | |
10 | assert(isstring(options) || is... | 20 | 0.000 s | 7.2% | |
6 | if nargin < 3 | 20 | 0.000 s | 6.6% | |
20 | tf = tf & (nnz(tf) == 1); | 20 | 0.000 s | 0.9% | |
All other lines | 0.000 s | 11.1% | |||
Totals | 0.003 s | 100% |
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
strlength | function | 20 | 0.001 s | 28.1% | |
Self time (built-ins, overhead, etc.) | 0.002 s | 71.9% | |||
Totals | 0.003 s | 100% |
Total lines in function | 22 |
Non-code lines (comments, blank lines) | 8 |
Code lines (lines that can run) | 14 |
Code lines that did run | 12 |
Code lines that did not run | 2 |
Coverage (did run/can run) | 85.71 % |
time | Calls | line | |
---|---|---|---|
1 | function tf = partialMatchString(str, options, N) | ||
2 | % PARTIALMATCHSTRING Partial matching for string options. | ||
3 | |||
4 | % Copyright 2017 The MathWorks, Inc. | ||
5 | |||
< 0.001 | 20 | 6 | if nargin < 3 |
< 0.001 | 20 | 7 | N = 1; |
< 0.001 | 20 | 8 | end |
9 | % Possible options to match should be string/char/cellstr | ||
< 0.001 | 20 | 10 | assert(isstring(options) || ischar(options) || iscellstr(options)) |
< 0.001 | 20 | 11 | if ~isstring(options) |
12 | options = string(options); | ||
< 0.001 | 20 | 13 | end |
14 | % String to match must be scalar text | ||
< 0.001 | 20 | 15 | if ~((ischar(str) && isrow(str)) || (isstring(str) && isscalar(str))) |
16 | tf = false(size(options)); | ||
< 0.001 | 20 | 17 | else |
0.002 | 20 | 18 | tf = strncmpi(str, options, max(N, strlength(str))); |
19 | % No duplicate matches | ||
< 0.001 | 20 | 20 | tf = tf & (nnz(tf) == 1); |
< 0.001 | 20 | 21 | end |
< 0.001 | 20 | 22 | end |
Other subfunctions in this file are not included in this listing.