time elapsed by a portion of the code

6 ビュー (過去 30 日間)
oblivious
oblivious 2012 年 7 月 11 日
Hello,
I need to know how much time a particular portion of my code consumes. I tried MATLAB profiler. But it displays how much time each function inside the code has taken along with its self time. But I need to define a particular portion or code segment inside my code (say for example a for loop) and need to know time it takes. How can I do it?
I do not want to use tic toc inside my code. I want things to be displayed like MATLAB profiler. It is required for my project. Can it be done?
Thanks in advance :)
-OBLI

採用された回答

Jan
Jan 2012 年 7 月 11 日
編集済み: Jan 2012 年 7 月 11 日
Please consider, that profile disables the JIT acceleration, such that lean loops will run significantly slower - a factor of 1000 is possible.
I'm not really sure how useful the profiler is for measuring the run-time, when it has large effects on the run-time. Therefore I use it to measure the memory consumption (not documented) and the calling tree. But the profiler is a good tool to find bottlenecks like the access of harddisks or network resources.
  1 件のコメント
oblivious
oblivious 2012 年 7 月 11 日
I need exact run-time. so i am not gonna use profiler anymore. thanks for the info simon

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

その他の回答 (1 件)

F.
F. 2012 年 7 月 11 日
If you don't like tic/toc or cputime ...
You can use the profiler in a local part of your code :
profile on
for
...
end
profile off
p = profile('info');
save myprofiledata p
And after
load myprofiledata
profview(0,p)

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by