|
| 1 | +### Performance testing |
| 2 | +based on Python unit testing framework where typical test suite looks like: |
| 3 | +``` |
| 4 | +class TestSuite(unittest.TestCase): |
| 5 | + # how many times function will be executed for more accurate measurements |
| 6 | + iter_number = 5 |
| 7 | +
|
| 8 | + @classmethod |
| 9 | + def setUpClass(cls): |
| 10 | + """ |
| 11 | + 1. Initalize object `TestResults` to work with results |
| 12 | + 2. Define some testing attributes, e.g. list of data length |
| 13 | + """ |
| 14 | + cls.test_results = TestResults() |
| 15 | + cls.total_data_length = [10**5, 10**6] |
| 16 | +
|
| 17 | + @classmethod |
| 18 | + def tearDownClass(cls): |
| 19 | + """Manipulate result through object `TestResults`""" |
| 20 | + cls.test_results.print() |
| 21 | +
|
| 22 | + def test_series_smth(self): |
| 23 | + """Test series.smth""" |
| 24 | + pyfunc = series_smth |
| 25 | + hpat_func = sdc.jit(pyfunc) |
| 26 | + for data_length in self.total_data_length: |
| 27 | + data = gen_some_data(data_length) |
| 28 | + test_data = pd.Series(data) |
| 29 | +
|
| 30 | + # calculate compilation time of `hpat_func` based in `pyfunc` |
| 31 | + compile_results = calc_compilation(pyfunc, test_data, iter_number=self.iter_number) |
| 32 | + # Warming up |
| 33 | + hpat_func(test_data) |
| 34 | +
|
| 35 | + # calculate execution and boxing/unboxing times of `hpat_func` |
| 36 | + exec_times, boxing_times = get_times(hpat_func, test_data, iter_number=self.iter_number) |
| 37 | +
|
| 38 | + # add these times to the results for further processing |
| 39 | + self.test_results.add('test_series_smth', 'JIT', test_data.size, exec_times, |
| 40 | + boxing_times, compile_results=compile_results) |
| 41 | +
|
| 42 | + # calculate execution times of `pyfunc` |
| 43 | + exec_times, _ = get_times(pyfunc, test_data, iter_number=self.iter_number) |
| 44 | +
|
| 45 | + # add these times to the results for further processing |
| 46 | + self.test_results.add('test_series_smth', 'Reference', test_data.size, exec_times) |
| 47 | +``` |
| 48 | + |
| 49 | +##### Extras: |
| 50 | +1. `test_perf_utils.py` contains utils for the development of the performance tests, |
| 51 | +which can be extended if it is required. The utils use extra Python modules `xlrd` and `openpyxl` |
| 52 | +which should be installed for correct work. |
| 53 | +2. `__init__.py` defines all the test suites. |
| 54 | + |
| 55 | +##### How to run performance testing: |
| 56 | +all:<br> |
| 57 | +`python -m sdc.runtests sdc.tests.tests_perf`<br> |
| 58 | +a single one:<br> |
| 59 | +`python -m sdc.runtests sdc.tests.tests_perf.test_perf_series_str.TestSeriesStringMethods.test_series_str_len` |
0 commit comments