Time consumed by a function in a code

I have made an equivalent function of variable fractional delay and running it with a for loop and with the other functions like xcorr in the code. I have to find the time taken by the code in executing the equivalent function only and not the xcorr function. I have used tic toc, but it gives the time for the whole code.

답변 (1개)

KSSV
KSSV 2020년 8월 17일

1 개 추천

Read about profiler. You can use tic toc.
t1 = tic ;
val = myfunction(inputs) ;
t1 = toc(t1) ;

댓글 수: 4

Rashi Mehrotra
Rashi Mehrotra 2020년 8월 17일
Yes I have used tic toc.
I have a for loop and inside that I have alternate vfd function and xcorr, I just have to check the time consumed for alternate vfd function.
N = 10 ;
t1 = zeros(N,1) ;
t2 = zeros(N,1) ;
for i = 1:N
ti = tic ;
val = vfd(input) ; % your function
t1(i) = toc(i) ;
tj = tic ;
val = xcorr(input) ;
t2(i) = toc(tj) ;
end
plot(1:N,t1,'r',1:N,t2,'b')
Also read about profiler.
Rashi Mehrotra
Rashi Mehrotra 2020년 8월 17일
there are two loops with vfd function and the time is growing as I am increasing the loop
Rashi Mehrotra
Rashi Mehrotra 2020년 8월 17일
This gives an error TOC must be a uint64 scalar. Please resolve.

댓글을 달려면 로그인하십시오.

카테고리

질문:

2020년 8월 17일

댓글:

2020년 8월 17일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by