Compute execution time without printing statement?

I am wondering if it is possible to compute the execution time using tic and toc statement but eliminating printing time?
I have a big program ... and it has a lot of printing statements in the middle ...
Is it possible to count the time without the time consumed by printing? or should I stop each printing statement one by one?

댓글 수: 2

Do you mean you have lots of disp( ) or fprintf( ) etc. statements, but want to somehow not count them in the timing results?
Yes I have fprintf and I do no want to count it in the excusion time ! ... is that possible?

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

답변 (1개)

Fabio Freschi
Fabio Freschi 2019년 9월 4일
편집: Fabio Freschi 2019년 9월 4일
You can just save the value in a variable
timerValue = tic;
% something very useful to do
tstop = toc(timerValue);

댓글 수: 4

Fabio Freschi
Fabio Freschi 2019년 9월 4일
편집: Fabio Freschi 2019년 9월 4일
The use of timerValue allows you to use different tic/toc statements without confusion or miscalculation
I have a lof of fprintf statement in my program ... I do not want these fprintf statements to be counted in the excusion time ... is this possible?
ok, sorry...
Count the time for printf wit tic/toc like I said and subctract the value from the time of computation
Rik
Rik 2019년 9월 4일
You could also try to shadow the fprintf function, but that is a dangerous business.

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

카테고리

도움말 센터File Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기

제품

태그

질문:

2019년 9월 4일

댓글:

Rik
2019년 9월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by