3
$\begingroup$

Is it possible to ask blender when each render tile starts/finishes rendering?

e.g. for a render time estimator

This used to be somewhat possible from the command line:

For example in blender 2.65a the elapsed time was printed, along with what tile was being traced:

Fra:1 Mem:12.59M (9.89M, peak 27.51M) | Mem: 6.82M, Peak: 6.96M | Scene, RenderLayer | Elapsed: 00:04.28 | Rendering | Path Tracing Tile 10/135
Fra:1 Mem:12.59M (9.89M, peak 27.51M) | Mem: 6.82M, Peak: 6.96M | Scene, RenderLayer | Elapsed: 00:04.41 | Rendering | Path Tracing Tile 11/135
Fra:1 Mem:12.59M (9.89M, peak 27.51M) | Mem: 6.96M, Peak: 6.96M | Scene, RenderLayer | Elapsed: 00:04.56 | Rendering | Path Tracing Tile 12/135
Fra:1 Mem:12.59M (9.89M, peak 27.51M) | Mem: 6.82M, Peak: 6.96M | Scene, RenderLayer | Elapsed: 00:05.99 | Rendering | Path Tracing Tile 13/135

though now with later versions of blender the elapsed time is no longer printed.
while you might be able to read blender's output with a script and get the time, is this possible with python?

Is there any way to get similar information to what is printed in the terminal with python?

$\endgroup$

2 Answers 2

4
$\begingroup$
from datetime import datetime
from bpy.app import handlers

TIMER = None

def start_timer(scene):
    global TIMER
    TIMER = datetime.now()

def elapsed(dummy):
    print("Elapsed:", datetime.now() - TIMER)

handlers.render_pre.append(start_timer)
handlers.render_stats.append(elapsed)

Example output:

Elapsed: 0:00:10.819869
Fra:1 Mem:7.10M (9.89M, Peak 17.07M) | Mem:1.21M, Peak:1.29M | Scene, RenderLayer | Path Tracing Tile 133/135
Elapsed: 0:00:10.863458
Fra:1 Mem:7.10M (9.89M, Peak 17.07M) | Mem:1.29M, Peak:1.29M | Scene, RenderLayer | Path Tracing Tile 134/135
Elapsed: 0:00:10.931486
Fra:1 Mem:7.10M (9.89M, Peak 17.07M) | Mem:1.21M, Peak:1.29M | Scene, RenderLayer | Path Tracing Tile 135/135
Elapsed: 0:00:11.466759
Fra:1 Mem:7.10M (9.89M, Peak 17.07M) | Mem:0.02M, Peak:1.29M | Scene, RenderLayer | Finished
Elapsed: 0:00:11.467813
Fra:1 Mem:7.08M (9.89M, Peak 17.07M) Sce: Scene Ve:0 Fa:0 La:0
Elapsed: 0:00:11.841684
Saved: /tmp/0001.png Time: 00:11.84 (Saving: 00:00.37)
$\endgroup$
1
  • $\begingroup$ The render_stats handler prints per tile? Will need to investigate. $\endgroup$
    – Fweeb
    Commented Aug 31, 2013 at 18:46
2
$\begingroup$

As far as I know, this is not currently accessible from the Python API (and I looked, because I'd love to add that to my Render Time Estimation add-on (shameless plug, I know)).

$\endgroup$
3
  • $\begingroup$ Perhaps there is some way to read the output with a script and feed that to python? (hacky, I know..) BTW, awesome addon, I use that all the time :) $\endgroup$
    – gandalf3
    Commented Aug 29, 2013 at 20:54
  • $\begingroup$ Worth investigating... will take a gander. Also, thank you. :) $\endgroup$
    – Fweeb
    Commented Aug 29, 2013 at 22:09
  • $\begingroup$ Did a quick check... in order for that to work, you'd need to run Blender as a Python subprocess and capture the strings that print to standard out. A better solution would probably be to add an event handler on the C side that fires each time a tile finishes... but even then you'd have to time each tile in C and expose that data to Python (since Python runs single-threaded in Blender, it can't reliably time multiple rendering tiles on multi-core system). $\endgroup$
    – Fweeb
    Commented Aug 30, 2013 at 6:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .