data transferred in calling a user defined functio

2019-09-04 19:31发布

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条回答
欢心
2楼-- · 2019-09-04 20:02

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);
查看更多
登录 后发表回答