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
This commit is contained in:
Sergey Sharybin 2023-06-15 13:40:17 +02:00 committed by Sergey Sharybin
parent da052ab9f6
commit 2d3c9bcee8
1 changed files with 7 additions and 7 deletions

View File

@ -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)