필터 지우기
필터 지우기

How to find computational time?

조회 수: 33 (최근 30일)
sanjai
sanjai 2021년 12월 12일
답변: Nasser Almabrok 2024년 2월 9일
I want to find the computation time for the Add in below code. How can I do that? Is there any command?
I can use tic & toc which will give the elapsed time. but I want to find computation / execution time.
Does anyone know? Please help me.
Matlab code
A=[1 2 3 4 56 7 8 9];
B=[7 8 9 4 55 1 2 3];
tic
for i=1:length(A)
Add(i) = A(i)+ 2* B(i);
end
toc
  댓글 수: 1
Image Analyst
Image Analyst 2021년 12월 12일
What is the difference between elapsed time and computation time? Of course your computer is also doing all kinds of stuff in the background and I'm not sure we can figure out the percentage of time it spent on only your MATLAB code. But what does it matter? It's the elapsed time that really matters in the real world, right?

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

채택된 답변

KSSV
KSSV 2021년 12월 12일
편집: KSSV 2021년 12월 12일
Read about tic toc.
t1 = tic ;
A=[1 2 3 4 56 7 8 9];
B=[7 8 9 4 55 1 2 3];
for i=1:length(A)
Add(i) = A(i)+ 2* B(i);
end
t1 = toc(t1)
t1 = 0.0289
Also read about profilier and timeit.

추가 답변 (2개)

Les Beckham
Les Beckham 2021년 12월 12일
You might be looking for cputime()
  댓글 수: 1
sanjai
sanjai 2021년 12월 12일
Exaclty im looking for CPU time.

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


Nasser Almabrok
Nasser Almabrok 2024년 2월 9일
I think you are looking for the time taken for the process to finish or to stop for one cycle. tic toc is your answer.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by