What reasons might a 100ms delayed return from a function have?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello community,
I defined a function XYZ as follows:
function [DATA] = XYZ(DATA)
%memsize of DATA is approx 400kB
%start timer
tic;
% create big temporary data (some MB)
tmp_data = createbigtemporarydata();
% assign small parts of the temporary data to DATA (approx 400kB)
DATA.X = tmp_data.Y;
% memsize of DATA stays arround 400kB
% remove big temporary data
clearvars tmp_data;
% measure time taken by the above steps
toc;
end
When calling this function from a skript the total time of execution measured from the script via
DATA = somedata400kB;
tic;
[DATA] = XYZ(DATA)
toc;
is approximately a 100ms longer than the time measured within the function. When using profiler, the end statement of XYZ does not take any time as it sometimes happens in for loops. As my code itself takes only some ms this is a huge slowdown.
What reasons might this behaviour have? What might I do better?
Thank you very much for your suggestions in advance!
0 Kommentare
Antworten (1)
Jan
am 18 Aug. 2012
Calling a function costs a certain overhead. If the function is removed from the memory before by a clear all, reloading the function needs a lot of time.
Does the PROFILEr reveal another bottleneck, e.g. in createbigtemporarydata()?
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!