File: test_performance.py

package info (click to toggle)
python-cffi 1.9.1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,440 kB
  • ctags: 4,423
  • sloc: python: 25,052; ansic: 12,528; asm: 116; makefile: 97; sh: 28
file content (52 lines) | stat: -rw-r--r-- 1,791 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import sys
from testing.embedding.test_basic import EmbeddingTests

if sys.platform == 'win32':
    import py
    py.test.skip("written with POSIX functions")


class TestPerformance(EmbeddingTests):
    def test_perf_single_threaded(self):
        perf_cffi = self.prepare_module('perf')
        self.compile('perf-test', [perf_cffi], opt=True)
        output = self.execute('perf-test')
        print('='*79)
        print(output.rstrip())
        print('='*79)

    def test_perf_in_1_thread(self):
        perf_cffi = self.prepare_module('perf')
        self.compile('perf-test', [perf_cffi], opt=True, threads=True,
                     defines={'PTEST_USE_THREAD': '1'})
        output = self.execute('perf-test')
        print('='*79)
        print(output.rstrip())
        print('='*79)

    def test_perf_in_2_threads(self):
        perf_cffi = self.prepare_module('perf')
        self.compile('perf-test', [perf_cffi], opt=True, threads=True,
                     defines={'PTEST_USE_THREAD': '2'})
        output = self.execute('perf-test')
        print('='*79)
        print(output.rstrip())
        print('='*79)

    def test_perf_in_4_threads(self):
        perf_cffi = self.prepare_module('perf')
        self.compile('perf-test', [perf_cffi], opt=True, threads=True,
                     defines={'PTEST_USE_THREAD': '4'})
        output = self.execute('perf-test')
        print('='*79)
        print(output.rstrip())
        print('='*79)

    def test_perf_in_8_threads(self):
        perf_cffi = self.prepare_module('perf')
        self.compile('perf-test', [perf_cffi], opt=True, threads=True,
                     defines={'PTEST_USE_THREAD': '8'})
        output = self.execute('perf-test')
        print('='*79)
        print(output.rstrip())
        print('='*79)