Strange results from tic / toc.

1 回表示 (過去 30 日間)
John Doe
John Doe 2013 年 5 月 9 日
I'm checking the running time of a function using tic/toc. I write the following in the command window (and execute it simultaneously):
tic
res = checkFunc('case2736sp',1:3000);
toc
Elapsed time is 0.080491 seconds.
where checkFunc returns a 2736x2500 full matrix.
What puzzles me is that I have to wait almost 20 seconds for the output saying the run time is only 80 ms.
Does anyone have a clue why this is?

採用された回答

cr
cr 2013 年 5 月 9 日
編集済み: cr 2013 年 5 月 9 日
Are you sure 'checkFunc' does NOT do a tic somewhere in its code? Anyways, this would be a better way to test:
tx = tic; res = checkFunc('case2736sp',1:3000); toc(tx)
  1 件のコメント
John Doe
John Doe 2013 年 5 月 9 日
You're of course right =) Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStrategy & Logic についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by