| 1 |
|
| 2 |
import sys |
| 3 |
from extra_tests.cffi_tests.embedding.test_basic import EmbeddingTests |
| 4 |
|
| 5 |
if sys.platform == 'win32': |
| 6 |
import pytest |
| 7 |
pytestmark = pytest.mark.skip("written with POSIX functions") |
| 8 |
|
| 9 |
|
| 10 |
class TestPerformance(EmbeddingTests): |
| 11 |
def test_perf_single_threaded(self): |
| 12 |
perf_cffi = self.prepare_module('perf') |
| 13 |
self.compile('perf-test', [perf_cffi], opt=True) |
| 14 |
output = self.execute('perf-test') |
| 15 |
print('='*79) |
| 16 |
print(output.rstrip()) |
| 17 |
print('='*79) |
| 18 |
|
| 19 |
def test_perf_in_1_thread(self): |
| 20 |
perf_cffi = self.prepare_module('perf') |
| 21 |
self.compile('perf-test', [perf_cffi], opt=True, threads=True, |
| 22 |
defines={'PTEST_USE_THREAD': '1'}) |
| 23 |
output = self.execute('perf-test') |
| 24 |
print('='*79) |
| 25 |
print(output.rstrip()) |
| 26 |
print('='*79) |
| 27 |
|
| 28 |
def test_perf_in_2_threads(self): |
| 29 |
perf_cffi = self.prepare_module('perf') |
| 30 |
self.compile('perf-test', [perf_cffi], opt=True, threads=True, |
| 31 |
defines={'PTEST_USE_THREAD': '2'}) |
| 32 |
output = self.execute('perf-test') |
| 33 |
print('='*79) |
| 34 |
print(output.rstrip()) |
| 35 |
print('='*79) |
| 36 |
|
| 37 |
def test_perf_in_4_threads(self): |
| 38 |
perf_cffi = self.prepare_module('perf') |
| 39 |
self.compile('perf-test', [perf_cffi], opt=True, threads=True, |
| 40 |
defines={'PTEST_USE_THREAD': '4'}) |
| 41 |
output = self.execute('perf-test') |
| 42 |
print('='*79) |
| 43 |
print(output.rstrip()) |
| 44 |
print('='*79) |
| 45 |
|
| 46 |
def test_perf_in_8_threads(self): |
| 47 |
perf_cffi = self.prepare_module('perf') |
| 48 |
self.compile('perf-test', [perf_cffi], opt=True, threads=True, |
| 49 |
defines={'PTEST_USE_THREAD': '8'}) |
| 50 |
output = self.execute('perf-test') |
| 51 |
print('='*79) |
| 52 |
print(output.rstrip()) |
| 53 |
print('='*79) |