Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit 02f9fc7

Browse files
densmirnshssf
authored andcommitted
Add README.md for performnace tests (#302)
Minor changes in TestResults.add()
1 parent fb0490f commit 02f9fc7

4 files changed

Lines changed: 68 additions & 8 deletions

File tree

sdc/tests/tests_perf/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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`

sdc/tests/tests_perf/test_perf_series_str.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ def _test_series_str(self, pyfunc, name, input_data=None):
190190
hpat_func(test_data)
191191

192192
exec_times, boxing_times = get_times(hpat_func, test_data, iter_number=self.iter_number)
193-
self.test_results.add(name, 'JIT', test_data.size, data_width, exec_times,
193+
self.test_results.add(name, 'JIT', test_data.size, exec_times, data_width,
194194
boxing_times, compile_results=compile_results, num_threads=self.num_threads)
195195
exec_times, _ = get_times(pyfunc, test_data, iter_number=self.iter_number)
196-
self.test_results.add(name, 'Reference', test_data.size, data_width, exec_times,
196+
self.test_results.add(name, 'Reference', test_data.size, exec_times, data_width,
197197
num_threads=self.num_threads)
198198

199199
def test_series_str_len(self):

sdc/tests/tests_perf/test_perf_unicode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ def _test_unicode(self, pyfunc, name):
111111
for data_size in self.total_data_size_bytes:
112112
for data_width in self.width:
113113
test_data = perf_data_gen(test_global_input_data_unicode_kind4, data_width, data_size)
114-
self.test_results.add(name, 'JIT', len(test_data), data_width, hpat_func(test_data))
115-
self.test_results.add(name, 'Reference', len(test_data), data_width, pyfunc(test_data))
114+
self.test_results.add(name, 'JIT', len(test_data), hpat_func(test_data), data_width)
115+
self.test_results.add(name, 'Reference', len(test_data), pyfunc(test_data), data_width)
116116

117117
def test_unicode_split(self):
118118
self._test_unicode(usecase_split, 'unicode_split')

sdc/tests/tests_perf/test_perf_utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,17 +168,18 @@ def grouped_data(self):
168168
columns = ['median', 'min', 'max', 'compile', 'boxing']
169169
return test_results_data.groupby(self.index)[columns].first().sort_values(self.index)
170170

171-
def add(self, test_name, test_type, data_size, data_width, test_results,
171+
def add(self, test_name, test_type, data_size, test_results, data_width=None,
172172
boxing_results=None, compile_results=None, num_threads=config.NUMBA_NUM_THREADS):
173173
"""
174174
Add performance testing timing results into global storage
175175
test_name: Name of test (1st column in grouped result)
176-
test_type: Type of test (2nd column in grouped result)
177-
test_data_width: Scalability attribute for input data (3rd column in grouped result)
176+
test_type: Type of test (3rd column in grouped result)
177+
data_size: Size of input data (4s column in grouped result)
178178
test_results: List of timing results of the experiment
179+
data_width: Scalability attribute for str input data (5s column in grouped result)
179180
boxing_results: List of timing results of the overhead (boxing/unboxing)
180181
compilation_time: Timing result of compilation
181-
num_threads: Value from NUMBA_NUM_THREADS
182+
num_threads: Value from NUMBA_NUM_THREADS (2nd column in grouped result)
182183
"""
183184
local_results = pandas.DataFrame({'name': test_name,
184185
'N': num_threads,

0 commit comments

Comments
 (0)