Cleanup: run autopep8 on tests/performance/benchmark
This file was skipped by source/tools/utils/autopep8_clean.py since it doesn't have a .py extension, running the autopep8 tool recursively detects Python scripts without extensions.
This commit is contained in:
parent
67a4908bfc
commit
65a1fcdaf7
|
@ -11,24 +11,30 @@ import sys
|
||||||
import time
|
import time
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
|
|
||||||
def find_blender_git_dir() -> pathlib.Path:
|
def find_blender_git_dir() -> pathlib.Path:
|
||||||
# Find .git directory of the repository we are in.
|
# Find .git directory of the repository we are in.
|
||||||
cwd = pathlib.Path.cwd()
|
cwd = pathlib.Path.cwd()
|
||||||
|
|
||||||
for path in [cwd] + list(cwd.parents):
|
for path in [cwd] + list(cwd.parents):
|
||||||
if (path / '.git').exists():
|
if (path / '.git').exists():
|
||||||
return path
|
return path
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_tests_base_dir(blender_git_dir: pathlib.Path) -> pathlib.Path:
|
def get_tests_base_dir(blender_git_dir: pathlib.Path) -> pathlib.Path:
|
||||||
# Benchmarks dir is next to the Blender source folder.
|
# Benchmarks dir is next to the Blender source folder.
|
||||||
return blender_git_dir.parent / 'benchmark'
|
return blender_git_dir.parent / 'benchmark'
|
||||||
|
|
||||||
|
|
||||||
def use_revision_columns(config: api.TestConfig) -> bool:
|
def use_revision_columns(config: api.TestConfig) -> bool:
|
||||||
return config.benchmark_type == "comparison" and \
|
return (
|
||||||
len(config.queue.entries) > 0 and \
|
config.benchmark_type == "comparison" and
|
||||||
not config.queue.has_multiple_revisions_to_build
|
len(config.queue.entries) > 0 and
|
||||||
|
not config.queue.has_multiple_revisions_to_build
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def print_header(config: api.TestConfig) -> None:
|
def print_header(config: api.TestConfig) -> None:
|
||||||
# Print header with revision columns headers.
|
# Print header with revision columns headers.
|
||||||
|
@ -42,6 +48,7 @@ def print_header(config: api.TestConfig) -> None:
|
||||||
header += f"{revision_name: <20} "
|
header += f"{revision_name: <20} "
|
||||||
print(header)
|
print(header)
|
||||||
|
|
||||||
|
|
||||||
def print_row(config: api.TestConfig, entries: List, end='\n') -> None:
|
def print_row(config: api.TestConfig, entries: List, end='\n') -> None:
|
||||||
# Print one or more test entries on a row.
|
# Print one or more test entries on a row.
|
||||||
row = ""
|
row = ""
|
||||||
|
@ -79,10 +86,13 @@ def print_row(config: api.TestConfig, entries: List, end='\n') -> None:
|
||||||
|
|
||||||
def match_entry(entry: api.TestEntry, args: argparse.Namespace):
|
def match_entry(entry: api.TestEntry, args: argparse.Namespace):
|
||||||
# Filter tests by name and category.
|
# Filter tests by name and category.
|
||||||
return fnmatch.fnmatch(entry.test, args.test) or \
|
return (
|
||||||
fnmatch.fnmatch(entry.category, args.test) or \
|
fnmatch.fnmatch(entry.test, args.test) or
|
||||||
entry.test.find(args.test) != -1 or \
|
fnmatch.fnmatch(entry.category, args.test) or
|
||||||
entry.category.find(args.test) != -1
|
entry.test.find(args.test) != -1 or
|
||||||
|
entry.category.find(args.test) != -1
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def run_entry(env: api.TestEnvironment,
|
def run_entry(env: api.TestEnvironment,
|
||||||
config: api.TestConfig,
|
config: api.TestConfig,
|
||||||
|
@ -159,6 +169,7 @@ def run_entry(env: api.TestEnvironment,
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def cmd_init(env: api.TestEnvironment, argv: List):
|
def cmd_init(env: api.TestEnvironment, argv: List):
|
||||||
# Initialize benchmarks folder.
|
# Initialize benchmarks folder.
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
@ -168,6 +179,7 @@ def cmd_init(env: api.TestEnvironment, argv: List):
|
||||||
env.init(args.build)
|
env.init(args.build)
|
||||||
env.unset_log_file()
|
env.unset_log_file()
|
||||||
|
|
||||||
|
|
||||||
def cmd_list(env: api.TestEnvironment, argv: List) -> None:
|
def cmd_list(env: api.TestEnvironment, argv: List) -> None:
|
||||||
# List devices, tests and configurations.
|
# List devices, tests and configurations.
|
||||||
print('DEVICES')
|
print('DEVICES')
|
||||||
|
@ -188,6 +200,7 @@ def cmd_list(env: api.TestEnvironment, argv: List) -> None:
|
||||||
for config_name in configs:
|
for config_name in configs:
|
||||||
print(config_name)
|
print(config_name)
|
||||||
|
|
||||||
|
|
||||||
def cmd_status(env: api.TestEnvironment, argv: List):
|
def cmd_status(env: api.TestEnvironment, argv: List):
|
||||||
# Print status of tests in configurations.
|
# Print status of tests in configurations.
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
@ -210,6 +223,7 @@ def cmd_status(env: api.TestEnvironment, argv: List):
|
||||||
if match_entry(row[0], args):
|
if match_entry(row[0], args):
|
||||||
print_row(config, row)
|
print_row(config, row)
|
||||||
|
|
||||||
|
|
||||||
def cmd_reset(env: api.TestEnvironment, argv: List):
|
def cmd_reset(env: api.TestEnvironment, argv: List):
|
||||||
# Reset tests to re-run them.
|
# Reset tests to re-run them.
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
@ -232,6 +246,7 @@ def cmd_reset(env: api.TestEnvironment, argv: List):
|
||||||
if args.test == '*':
|
if args.test == '*':
|
||||||
shutil.rmtree(config.logs_dir)
|
shutil.rmtree(config.logs_dir)
|
||||||
|
|
||||||
|
|
||||||
def cmd_run(env: api.TestEnvironment, argv: List, update_only: bool):
|
def cmd_run(env: api.TestEnvironment, argv: List, update_only: bool):
|
||||||
# Run tests.
|
# Run tests.
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
@ -271,6 +286,7 @@ def cmd_run(env: api.TestEnvironment, argv: List, update_only: bool):
|
||||||
|
|
||||||
print("\nfile://" + str(html_filepath))
|
print("\nfile://" + str(html_filepath))
|
||||||
|
|
||||||
|
|
||||||
def cmd_graph(argv: List):
|
def cmd_graph(argv: List):
|
||||||
# Create graph from a given JSON results file.
|
# Create graph from a given JSON results file.
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
@ -291,6 +307,7 @@ def cmd_graph(argv: List):
|
||||||
graph = api.TestGraph(json_files)
|
graph = api.TestGraph(json_files)
|
||||||
graph.write(pathlib.Path(args.output))
|
graph.write(pathlib.Path(args.output))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
usage = ('benchmark <command> [<args>]\n'
|
usage = ('benchmark <command> [<args>]\n'
|
||||||
'\n'
|
'\n'
|
||||||
|
@ -317,8 +334,8 @@ def main():
|
||||||
argv = sys.argv[2:]
|
argv = sys.argv[2:]
|
||||||
blender_git_dir = find_blender_git_dir()
|
blender_git_dir = find_blender_git_dir()
|
||||||
if blender_git_dir == None:
|
if blender_git_dir == None:
|
||||||
sys.stderr.write('Error: no blender git repository found from current working directory\n')
|
sys.stderr.write('Error: no blender git repository found from current working directory\n')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if args.command == 'graph':
|
if args.command == 'graph':
|
||||||
cmd_graph(argv)
|
cmd_graph(argv)
|
||||||
|
@ -349,5 +366,6 @@ def main():
|
||||||
else:
|
else:
|
||||||
sys.stderr.write(f'Unknown command: {args.command}\n')
|
sys.stderr.write(f'Unknown command: {args.command}\n')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue