filter function - delay at the first run
이전 댓글 표시
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
답변 (2개)
Sean de Wolski
2012년 4월 23일
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
2012년 4월 23일
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?
카테고리
도움말 센터 및 File Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!