Last active
December 1, 2022 06:41
-
-
Save UuuNyaa/e6af0b49f7e8b5a1eea467d908ff3527 to your computer and use it in GitHub Desktop.
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
| # Output results to the system console | |
| from datetime import datetime | |
| import functools | |
| import bpy | |
| prop_name2values = { | |
| 'bpy.context.scene.eevee.taa_render_samples' : [32, 1, 16, 64, 128, 512], | |
| 'bpy.context.scene.eevee.use_gtao' : [True, False], | |
| 'bpy.context.scene.eevee.use_bloom' : [True, False], | |
| 'bpy.context.scene.eevee.bokeh_max_size' : [16, 0, 1, 32, 64, 128, 256], | |
| 'bpy.context.scene.eevee.sss_samples' : [7, 1, 4, 8, 16, 32], | |
| 'bpy.context.scene.eevee.use_ssr_halfres' : [False, True], | |
| 'bpy.context.scene.eevee.use_ssr' : [True, False], | |
| 'bpy.context.scene.eevee.use_motion_blur' : [False, True], | |
| 'bpy.context.scene.eevee.shadow_cube_size': ['512', '64', '128', '256', '1024', '2048', '4096'], | |
| 'bpy.context.scene.eevee.shadow_cascade_size': ['1024', '64', '128', '256', '512', '2048', '4096'], | |
| 'bpy.context.scene.render.image_settings.file_format': ['JPEG', 'BMP', 'IRIS', 'PNG', 'JPEG2000', 'TARGA', 'TARGA_RAW', 'CINEON', 'DPX', 'OPEN_EXR_MULTILAYER', 'OPEN_EXR', 'HDR', 'TIFF', 'AVI_JPEG', 'AVI_RAW', 'FFMPEG'], | |
| 'bpy.context.scene.render.use_compositing' : [False, True], | |
| 'bpy.context.scene.render.use_sequencer' : [False, True], | |
| 'bpy.context.view_layer.use_pass_combined' : [False, True], | |
| 'bpy.context.view_layer.use_pass_z' : [False, True], | |
| 'bpy.context.view_layer.use_pass_mist' : [False, True], | |
| 'bpy.context.view_layer.use_pass_normal' : [False, True], | |
| 'bpy.context.view_layer.use_pass_diffuse_direct' : [False, True], | |
| 'bpy.context.view_layer.use_pass_diffuse_color' : [False, True], | |
| 'bpy.context.view_layer.use_pass_glossy_direct' : [False, True], | |
| 'bpy.context.view_layer.use_pass_glossy_color' : [False, True], | |
| 'bpy.context.view_layer.eevee.use_pass_volume_direct' : [False, True], | |
| 'bpy.context.view_layer.use_pass_emit' : [False, True], | |
| 'bpy.context.view_layer.use_pass_environment' : [False, True], | |
| 'bpy.context.view_layer.use_pass_shadow' : [False, True], | |
| 'bpy.context.view_layer.use_pass_ambient_occlusion' : [False, True], | |
| 'bpy.context.view_layer.eevee.use_pass_bloom' : [False, True], | |
| 'bpy.context.view_layer.use_pass_cryptomatte_object' : [False, True], | |
| 'bpy.context.view_layer.use_pass_cryptomatte_material' : [False, True], | |
| 'bpy.context.view_layer.use_pass_cryptomatte_asset' : [False, True], | |
| } | |
| handlers = { | |
| 'frame_change_pre': bpy.app.handlers.frame_change_pre, | |
| 'frame_change_post': bpy.app.handlers.frame_change_post, | |
| 'render_pre': bpy.app.handlers.render_pre, | |
| 'render_post': bpy.app.handlers.render_post, | |
| } | |
| def log_timestamp(message, *args): | |
| print('[BENCHMARK]', datetime.now(), message, flush=True) | |
| def register_handlers(): | |
| for name, registry in handlers.items(): | |
| if len(registry) > 0: | |
| registry.clear() | |
| registry.append(functools.partial(log_timestamp, name)) | |
| def resolve_data_path(context, data_path): | |
| path_fragments = data_path.split('.') | |
| if len(path_fragments) < 2: | |
| return (context, data_path) | |
| return (eval('.'.join(path_fragments[:-1])), path_fragments[-1]) | |
| def initialize_settings(): | |
| for name, values in prop_name2values.items(): | |
| data, prop = resolve_data_path(bpy.context, name) | |
| setattr(data, prop, values[0]) | |
| def benchmark_settings(): | |
| for name, values in prop_name2values.items(): | |
| data, prop = resolve_data_path(bpy.context, name) | |
| for value in values: | |
| log_timestamp(f'{name}: {value}') | |
| setattr(data, prop, value) | |
| bpy.ops.render.render(animation=True) | |
| # reset to minimul | |
| setattr(data, prop, values[0]) | |
| def benchmark_mesh_use_auto_smooth(): | |
| log_timestamp('bpy.data.meshes[].use_auto_smooth: False') | |
| for mesh in bpy.data.meshes: | |
| mesh.use_auto_smooth = False | |
| bpy.ops.render.render(animation=True) | |
| for mesh in bpy.data.meshes: | |
| mesh.use_auto_smooth = True | |
| def benchmark_material_blend_method(): | |
| for method in ['OPAQUE', 'HASHED']: | |
| log_timestamp(f'bpy.data.materials[].method: {method}') | |
| for material in bpy.data.materials: | |
| material.blend_method = method | |
| material.shadow_method = method | |
| bpy.ops.render.render(animation=True) | |
| register_handlers() | |
| initialize_settings() | |
| benchmark_settings() | |
| benchmark_mesh_use_auto_smooth() | |
| benchmark_material_blend_method() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment