From 2d3c9bcee894cc803883b88f618ff06f26e8d4b2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 15 Jun 2023 13:40:17 +0200 Subject: [PATCH] Benchmark: Pack python expression into a single line There should be no functional changes for the typical usecase, but it allows to have more tricky setups like pointing to a BAT script to override some configuration. The issue is that BAT scripts do not support new lines in the command line arguments. That's where single-line python expression helps. For example, it is possible to point benchmark script to a blender.bat which contains blender.exe --python-expr "import bpy; bpy.context.preferences.addons['cycles'].preferences.use_oneapirt = False" %* to have side-by-side numbers of oneAPI with and without HW RT. Without this change the %* is which did not work: the BAT script did not "see" part of the command line past the new line. Pull Request: https://projects.blender.org/blender/blender/pulls/109006 --- tests/performance/api/environment.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/performance/api/environment.py b/tests/performance/api/environment.py index 38f2a80922f..d4a9ac5fc67 100644 --- a/tests/performance/api/environment.py +++ b/tests/performance/api/environment.py @@ -235,13 +235,13 @@ class TestEnvironment: args = base64.b64encode(pickle.dumps(args)) output_prefix = 'TEST_OUTPUT: ' - expression = (f'import sys, pickle, base64\n' - f'sys.path.append(r"{package_path}")\n' - f'import {modulename}\n' - f'args = pickle.loads(base64.b64decode({args}))\n' - f'result = {modulename}.{functionname}(args)\n' - f'result = base64.b64encode(pickle.dumps(result))\n' - f'print("\\n{output_prefix}" + result.decode() + "\\n")\n') + expression = (f'import sys, pickle, base64;' + f'sys.path.append(r"{package_path}");' + f'import {modulename};' + f'args = pickle.loads(base64.b64decode({args}));' + f'result = {modulename}.{functionname}(args);' + f'result = base64.b64encode(pickle.dumps(result));' + f'print("\\n{output_prefix}" + result.decode() + "\\n")') expr_args = blender_args + ['--python-expr', expression] lines = self.call_blender(expr_args, foreground=foreground)