问题
I need to analyze a big source code.Code contains several function calls. Depending upon the computation and communication between function calls, i will need to figure out the best configuration scheme for the overall execution of the source code.
According to me ,
Data communicated in calling a function(if it is on different machine,server etc)=Input Data Size+Output Data Size
for getting the input data size and output data size ,i think i should rewrite all functions to have variable number of inputs and variables outputs.
[varargout] samplefunction(varargin) {
FOR i=0:nargin
inputdata=inputdata+sizeof(varargin(i));
% Do stuff here
}
isn't there a way to calculate size of cell array(varargin/varargout) directly in Matlab ?
or if u can suggest another approach to measure communicated data between function call ?
回答1:
A call to cellfun() with string inputs would be very fast:
sizes = [cellfun('size',varargin,1); cellfun('size',varargin,2)];
or
lenghts = cellfun('length',varargin);
or
numels = cellfun('prodofsize',varargin);
来源:https://stackoverflow.com/questions/17055877/data-transferred-in-calling-a-user-defined-function