diff options
author | Brecht Van Lommel <brecht@blender.org> | 2020-03-15 02:30:26 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2020-03-24 22:58:31 +0300 |
commit | adab11adf58b1ed816ba8f9979739b0b75e1dbb1 (patch) | |
tree | b94165ac004ee841090584756ad10be37b33f16c /tests/performance/api/test.py | |
parent | 394a1373a0cd20b7d0660df4bf80e1231e33cba9 (diff) |
Tests: prototype for performance testing frameworkperformance-test
Diffstat (limited to 'tests/performance/api/test.py')
-rw-r--r-- | tests/performance/api/test.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/performance/api/test.py b/tests/performance/api/test.py new file mode 100644 index 00000000000..53c5fc0c3cc --- /dev/null +++ b/tests/performance/api/test.py @@ -0,0 +1,42 @@ + +import abc +from . import TestEnvironment +from typing import Dict + +class Test: + @abc.abstractmethod + def name(self) -> str: + """ + Name of the test. + """ + + def use_device(self) -> bool: + """ + Test uses a specific CPU or GPU device. + """ + return False + + @abc.abstractmethod + def run(self, env: TestEnvironment) -> Dict: + """ + Execute the test and report results. + """ + +class TestCollection: + def __init__(self, env: TestEnvironment): + import importlib + import pkgutil + import tests + + self.tests = [] + + for _, modname, _ in pkgutil.iter_modules(tests.__path__, 'tests.'): + module = importlib.import_module(modname) + self.tests += module.generate(env) + + def find(self, test_name: str): + for test in self.tests: + if test.name() == test_name: + return test + + return None |