filter function - delay at the first run
Ältere Kommentare anzeigen
Hi all, I have a question related to the filter function. I noticed a delay the first time this function is called for instance in a for loop.
Let's start from this code:
function y = dummy(x)
y = zeros(size(x));
[b, a] = cheby1(4, 0.5, 0.1);
for i = 1:size(x, 2)
tic
y(:, i) = filter(b, a, x(:, i));
toc
end
end
with x = rand(10000, 64);
Every time the function dummy is called, the computational time at the first iteration (i==1) is higher (e.g. ~50 ms in my workstation).
Do you any idea why it happens? There is a way to avoid it?
Thanks
Luca
Antworten (2)
Sean de Wolski
am 23 Apr. 2012
That is likely the JIT compiler taking a little extra time on the first iteration but then being much slower.
What does the timing look like if you turn the JIT off?
feature accel off
Jan
am 23 Apr. 2012
In the line:
y(:, i) = filter(b, a, x(:, i));
memory is reserved for x(:,1). Perhaps this memory is reused later by the smart JIT? This is a pure guessing.
Just for curiosity: Do you know that the loop over i is not necessary and that:
y = filter(b, a, x)
would use all cores for multi-threading, because x has more than 16 columns?
Kategorien
Mehr zu Digital Filter Analysis finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!