is it possible to measure the time it takes to render a figure

9 ビュー (過去 30 日間)
Jim Hokanson
Jim Hokanson 2017 年 12 月 23 日
コメント済み: Jim Hokanson 2017 年 12 月 23 日
I would like to log the time it takes to render a figure. Is there a way to listen for the "start" and "end" of rendering a figure?
We could log render time by measuring the time it takes to run a drawnow command (or some variant of the drawnow command ...).
h_tic = tic;
drawnow();
elapsed_time = toc(h_tic);
This however forces rendering to occur. I'd prefer a general solution that logs rendering, when it happens to occur. Thus I think I need to use some sort of listening mechanism where I start and stop a measurement based on the start and stop of rendering.

採用された回答

Walter Roberson
Walter Roberson 2017 年 12 月 23 日
No, in current versions of MATLAB there is no way to measure the time that it takes to render the figure. drawnow() and pause() ensure that the rendering subsystem have accepted the commands before they continue, but the rendering engine runs in a different thread and "accepting" the commands does not tell you anything about when the rendering is finished. The rendering might go through OpenGL layers and might get partly handled by a GPU and other items outside the control of MATLAB, so even knowing when the rendering layer had submitted commands to another hardware level would not tell you how long the figure took to render.
The closest you can get in all of this is to use the third party Psychtoolbox, which keeps track at a frame level -- but is fairly restricted as to what can be drawn.
  1 件のコメント
Jim Hokanson
Jim Hokanson 2017 年 12 月 23 日
I was hoping that there might be events which indicated rendering was starting and ending. I would think at least on the ending side that some markedClean like event could be found.

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

その他の回答 (1 件)

the cyclist
the cyclist 2017 年 12 月 23 日
Depending on exactly what you want to know, profiling your code might get what you want.
  1 件のコメント
Jim Hokanson
Jim Hokanson 2017 年 12 月 23 日
Thanks. I want this to be a generic solution that logs render time. Profiling slows down execution and doesn't actually show rendering time (I think) unless you have explicit calls to render which are timed. I'll update my question accordingly.

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

カテゴリ

Help Center および File ExchangeTiming and presenting 2D and 3D stimuli についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by