File: test_benchmark.py

package info (click to toggle)
python-mutf8 1.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 132 kB
  • sloc: python: 342; ansic: 207; makefile: 3
file content (28 lines) | stat: -rw-r--r-- 860 bytes parent folder | download | duplicates (2)
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
import pytest

import mutf8.mutf8 as pymutf8
import mutf8.cmutf8 as cmutf8


@pytest.mark.parametrize('group,decoder', (
    ('pymutf8', pymutf8.decode_modified_utf8),
    ('cmutf8', cmutf8.decode_modified_utf8)
))
@pytest.mark.slow
def test_decode(group, decoder, benchmark):
    """Compare the performance of the python and C decoders."""
    benchmark.group = 'MUTF-8 Decoding'
    benchmark.extra_info['group'] = group
    benchmark(decoder, b'\xED\xA0\xBD\xED\xB8\x88')


@pytest.mark.parametrize('group,encoder', (
    ('pymutf8', pymutf8.encode_modified_utf8),
    ('cmutf8', cmutf8.encode_modified_utf8)
))
@pytest.mark.slow
def test_encode(group, encoder, benchmark):
    """Compare the performance of the python and C encoders."""
    benchmark.group = 'MUTF-8 Encoding'
    benchmark.extra_info['group'] = group
    benchmark(encoder, '\U0001F608')