makeValidName>getMakeValidFcnHandle/makeValid (Calls: 5, Time: 0.009 s)
Generated 04-Jun-2021 04:11:16 using performance time.
nested function in file C:\Program Files\MATLAB\R2020b\toolbox\matlab\lang\+matlab\+lang\makeValidName.m
Copy to new window for comparing multiple runs
Function Name | Function Type | Calls |
...n)makeValid(n,@replaceWithUnderscore) | anonymous function | 5 |
Line Number | Code | Calls | Total Time | % Time | Time Plot |
154 | name = erase(name, whitespace)... | 5 | 0.003 s | 34.6% | |
153 | name = regexprep(name, '(?<... | 5 | 0.002 s | 22.4% | |
158 | name = invalidReplacementFun(n... | 5 | 0.001 s | 14.1% | |
162 | if iskeyword(name(keywordIdx)) | 7 | 0.001 s | 7.6% | |
172 | isTooLong = (strlength(name) &... | 5 | 0.000 s | 4.2% | |
All other lines | 0.002 s | 17.2% | |||
Totals | 0.009 s | 100% |
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
erase | function | 5 | 0.003 s | 29.5% | |
...eValidFcnHandle/replaceWithUnderscore | nested function | 5 | 0.000 s | 4.8% | |
iskeyword | function | 7 | 0.000 s | 4.4% | |
makeValidName>@(token_1)upper(token_1) | anonymous function | 11 | 0.000 s | 2.3% | |
Self time (built-ins, overhead, etc.) | 0.005 s | 59.1% | |||
Totals | 0.009 s | 100% |
Total lines in function | 31 |
Non-code lines (comments, blank lines) | 11 |
Code lines (lines that can run) | 20 |
Code lines that did run | 15 |
Code lines that did not run | 5 |
Coverage (did run/can run) | 75.00 % |
time | Calls | line | |
---|---|---|---|
148 | function name = makeValid(name, invalidReplacementFun) | ||
149 | % Remove leading and trailing whitespace and | ||
150 | % replace embedded whitespace with camel/mixed casing. | ||
< 0.001 | 5 | 151 | whitespace = compose([" ", "\f", "\n", "\r", "\t", "\v"]); |
< 0.001 | 5 | 152 | if any(contains(name, whitespace)) |
0.002 | 5 | 153 | name = regexprep(name, '(?<=\S)\s+([a-z])', '${upper($1)}'); |
0.003 | 5 | 154 | name = erase(name, whitespace); |
< 0.001 | 5 | 155 | end |
156 | |||
157 | % Replace invalid characters as specified by ReplacementStyle. | ||
0.001 | 5 | 158 | name = invalidReplacementFun(name); |
159 | |||
160 | % Prepend keyword with PREFIX and camel case. | ||
< 0.001 | 5 | 161 | for keywordIdx = 1:numel(name) |
< 0.001 | 7 | 162 | if iskeyword(name(keywordIdx)) |
163 | name{keywordIdx} = [prefix, upper(name{keywordIdx}(1)), ... | ||
164 | lower(name{keywordIdx}(2:end))]; | ||
< 0.001 | 7 | 165 | end |
< 0.001 | 7 | 166 | end |
167 | |||
168 | % Insert PREFIX if the first column is non-letter. | ||
< 0.001 | 5 | 169 | name = regexprep(name,'^(?![a-z])', prefix, 'emptymatch', 'ignorecase'); |
170 | |||
171 | % Truncate NAME to NAMLENGTHMAX. | ||
< 0.001 | 5 | 172 | isTooLong = (strlength(name) > namelengthmax); |
< 0.001 | 5 | 173 | if any(isTooLong) |
174 | for isTooLongIdx = reshape(find(isTooLong), 1, []) | ||
175 | name{isTooLongIdx} = name{isTooLongIdx}(1:namelengthmax); | ||
176 | end | ||
< 0.001 | 5 | 177 | end |
< 0.001 | 5 | 178 | end |
Other subfunctions in this file are not included in this listing.