Created
February 23, 2019 02:00
-
-
Save qubodup/ccafbc014eba52c20c4e5459f171182c to your computer and use it in GitHub Desktop.
Blender Tile Size Performance Test Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import time | |
from datetime import datetime | |
from bpy.app import handlers | |
print("================") | |
global DEVICES | |
global RESOLUTIONS | |
global CLOCK | |
global DURATION | |
global RESNOW | |
global DEVNOW | |
global LOGLINE | |
global LOGFILE | |
LOGPATH = 'C:/Cache/log.csv' | |
DEVICES = ["CPU", "GPU"] | |
#RESOLUTIONS = [[8,8],[16,16],[32,32],[48,48],[64,64],[80,80],[128,128],[256,256],[320,320],[480,480],[512,512],[640,640],[320,270],[160,135],[480,405],[1920,1080],[1280,720],[960,540]] | |
#RESOLUTIONS = [[320,270],[160,135]] | |
RESOLUTIONS = [[16,16],[32,32],[48,48],[64,64],[80,80],[128,128],[256,256],[320,320],[480,480],[512,512],[640,640],[320,270],[160,135],[480,405],[1920,1080],[1280,720],[960,540]] | |
DEVNOW = 0 | |
RESNOW = 0 | |
RESMAX = len(RESOLUTIONS) - 1 | |
def start_timer(scene): | |
global CLOCK | |
print("RENDER STARTING", bpy.context.scene.cycles.device, bpy.context.scene.render.tile_x, bpy.context.scene.render.tile_y) | |
CLOCK = datetime.now() | |
def elapsed(dummy): | |
global DURATION | |
global CLOCK | |
global LOGLINE | |
global RESNOW | |
global DEVNOW | |
DURATION = datetime.now() - CLOCK | |
LOGLINE = DEVICES[DEVNOW] + ", " + str(RESOLUTIONS[RESNOW][0]) + ", " + str(RESOLUTIONS[RESNOW][1]) | |
LOGLINE = LOGLINE + ", " + str(DURATION) + "\n" | |
print(LOGLINE) | |
with open(LOGPATH, "a+") as logfile: | |
logfile.write(LOGLINE) | |
RESNOW = RESNOW + DEVNOW | |
DEVNOW = abs(DEVNOW - 1) | |
if RESNOW <= RESMAX: | |
render_next() | |
else: | |
print("COMPLETE") | |
def render_next(): | |
bpy.context.scene.cycles.device = DEVICES[DEVNOW] | |
bpy.context.scene.render.tile_x = RESOLUTIONS[RESNOW][0] | |
bpy.context.scene.render.tile_y = RESOLUTIONS[RESNOW][1] | |
print(bpy.context.scene.cycles.device, bpy.context.scene.render.tile_x, bpy.context.scene.render.tile_y) | |
bpy.ops.render.render() | |
handlers.render_pre.clear() | |
handlers.render_complete.clear() | |
handlers.render_pre.append(start_timer) | |
handlers.render_complete.append(elapsed) | |
render_next() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment