This is a static copy of a profile report

Home

WorkspaceListener>WorkspaceListener.workspaceUpdatedCorrectContext (Calls: 3, Time: 0.014 s)
Generated 18-May-2021 16:05:14 using performance time.
class method in file /usr/local/MATLAB/R2021a/toolbox/matlab/datatools/datatoolsservices/matlab/+internal/+matlab/+datatoolsservices/WorkspaceListener.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
....WorkspaceEventType.VARIABLE_CHANGED)anonymous function3
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
122
elseif isempty(aEvent) || ~isp...
30.005 s36.3%
131
varList = join(varNames, ''','...
30.002 s16.6%
142
if isAnsOnlyVariableChange &am...
30.002 s15.5%
143
internal.matlab.datatoolsservi...
30.002 s13.4%
125
varNames = aEvent.Details.varn...
30.001 s7.2%
All other lines  0.002 s11.0%
Totals  0.014 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
ispropfunction30.003 s22.2%
joinfunction30.002 s13.9%
...istener>WorkspaceListener.logEventclass method30.002 s11.6%
cell.ismemberfunction30.001 s10.0%
MVMEvent>MVMEvent.subsrefclass method90.001 s9.6%
Self time (built-ins, overhead, etc.)  0.005 s32.8%
Totals  0.014 s100% 
Code Analyzer results
Line numberMessage
Coverage results
Show coverage for parent directory
Total lines in function76
Non-code lines (comments, blank lines)28
Code lines (lines that can run)48
Code lines that did run18
Code lines that did not run30
Coverage (did run/can run)37.50 %
Function listing
time 
Calls 
 line
 114 
        function workspaceUpdatedCorrectContext(aEvent, expectVarNames, eventType)
 115 
            % Called by the event listener.  Corrects the context by executing
 116 
            % in the user's workspace, using the builtin _dtcallback function.
      3 
 117
            doUpdate = true; 
< 0.001 
      3 
 118
            varNames = {}; 
 119 

< 0.001 
      3 
 120
            if ~expectVarNames 
 121 
                varList = [];
  0.005 
      3 
 122
            elseif isempty(aEvent) || ~isprop(aEvent, 'Details') || ~isfield(aEvent.Details, 'varnames') 
 123 
                varList = '';
      3 
 124
            else 
  0.001 
      3 
 125
                varNames = aEvent.Details.varnames.item; 
< 0.001 
      3 
 126
                if ~iscellstr(varNames) %#ok<ISCLSTR> 
< 0.001 
      3 
 127
                    varNames = {varNames}; 
      3 
 128
                end 
 129 
                
< 0.001 
      3 
 130
                if ~isempty(varNames) 
  0.002 
      3 
 131
                    varList = join(varNames, ''','''); 
 132 
                else
 133 
                    varList = '';
      3 
 134
                end 
 135 

 136 
                
< 0.001 
      3 
 137
                isAnsOnlyVariableChange = length(varNames) == 1 && ... 
      3 
 138
                    strcmp(varNames{1}, 'ans') && ... 
      3 
 139
                    isfield(aEvent.Details, 'VariablesChangedEvent'); 
 140 
                % Short circuit for ans updates if ans isn't a variable in
 141 
                % the workspace
  0.002 
      3 
 142
                if isAnsOnlyVariableChange && ~ismember('ans', evalin('debug', 'who')) 
  0.002 
      3 
 143
                    internal.matlab.datatoolsservices.WorkspaceListener.logEvent('Ignoring new ans VariablesChanged event\n'); 
< 0.001 
      3 
 144
                    return; 
 145 
                end
 146 
    
 147 
                % Throttle amount the updates ignore anything < throttleTime
 148 
                currTime = posixtime(datetime('now'));
 149 
                lastUpdateTime = internal.matlab.datatoolsservices.WorkspaceListener.getSetLastUpdateTime();
 150 
                eventQueuingEnabled = internal.matlab.datatoolsservices.WorkspaceListener.eventQueueEnabled;
 151 
                timeDiff = currTime - lastUpdateTime;
 152 
                if ~isAnsOnlyVariableChange
 153 
                    tt = internal.matlab.datatoolsservices.WorkspaceListener.eventThrottleTime;
 154 
                else
 155 
                    tt = internal.matlab.datatoolsservices.WorkspaceListener.ansThrottleTime;
 156 
                end
 157 
                if ~(~eventQueuingEnabled || timeDiff >= tt || timeDiff < 0)
 158 
                    doUpdate = false;                    
 159 
                end
 160 
                % If the time difference between updates just for ans
 161 
                % has been more than throttleTime, do the update.  Also, if
 162 
                % the time difference is less than 0 (which can happen
 163 
                % in MOL when the location of the MATLAB session is
 164 
                % different from previous logins), also do the update to
 165 
                % get times sync'ed up for this session.
 166 
                internal.matlab.datatoolsservices.WorkspaceListener.getSetLastUpdateTime(currTime);
 167 
            end
 168 

 169 
            if doUpdate
 170 
                % Dispatch Event
 171 
                internal.matlab.datatoolsservices.WorkspaceListener.logEvent("Dispatching event(%s) for variables: %s\n", string(eventType), string(varList));
 172 
                internal.matlab.datatoolsservices.WorkspaceListener.executeWorkspaceListeners(varList, eventType);
 173 
            else
 174 
                % Coalesce and Queue event
 175 
                % Always queue ans VariablesChanged events to avoid 2 events
 176 
                % being fired.  This will mean all ans updates are delayed
 177 
                % by throttleTime but that should be sufficient to avoid two
 178 
                % events firing.
 179 
                if isAnsOnlyVariableChange
 180 
                    % Ignore ans updates as they will cause an infinite
 181 
                    % loop.  Calling the callbacks triggers workspace
 182 
                    % updates around ans.  This happens if we execute
 183 
                    % either when MATLAB IDLE or via the event queue timer.
 184 
                    internal.matlab.datatoolsservices.WorkspaceListener.logEvent('Not queuing new ans VariablesChanged event\n');
 185 
                else
 186 
                    internal.matlab.datatoolsservices.WorkspaceListener.queueEvent(varNames, eventType);
 187 
                end
 188 
            end
 189 
        end

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