|
1 | 1 | """CodSpeed benchmarks for uuid-utils""" |
| 2 | + |
2 | 3 | import uuid |
3 | 4 |
|
4 | 5 | import pytest |
5 | | - |
6 | 6 | import uuid_utils |
7 | 7 |
|
8 | 8 | node = uuid.getnode() |
|
11 | 11 | # UUID Generation Benchmarks |
12 | 12 | @pytest.mark.benchmark |
13 | 13 | def test_uuid1_stdlib(benchmark): |
14 | | - """Benchmark stdlib UUID v1 generation""" |
15 | 14 | benchmark(lambda: uuid.uuid1(node)) |
16 | 15 |
|
17 | 16 |
|
18 | 17 | @pytest.mark.benchmark |
19 | 18 | def test_uuid1_utils(benchmark): |
20 | | - """Benchmark uuid_utils UUID v1 generation""" |
21 | 19 | benchmark(lambda: uuid_utils.uuid1(node)) |
22 | 20 |
|
23 | 21 |
|
24 | 22 | @pytest.mark.benchmark |
25 | 23 | def test_uuid3_stdlib(benchmark): |
26 | | - """Benchmark stdlib UUID v3 generation""" |
27 | 24 | benchmark(lambda: uuid.uuid3(namespace=uuid.NAMESPACE_DNS, name="python.org")) |
28 | 25 |
|
29 | 26 |
|
30 | 27 | @pytest.mark.benchmark |
31 | 28 | def test_uuid3_utils(benchmark): |
32 | | - """Benchmark uuid_utils UUID v3 generation""" |
33 | | - benchmark(lambda: uuid_utils.uuid3(namespace=uuid_utils.NAMESPACE_DNS, name="python.org")) |
| 29 | + benchmark( |
| 30 | + lambda: uuid_utils.uuid3(namespace=uuid_utils.NAMESPACE_DNS, name="python.org") |
| 31 | + ) |
34 | 32 |
|
35 | 33 |
|
36 | 34 | @pytest.mark.benchmark |
37 | 35 | def test_uuid4_stdlib(benchmark): |
38 | | - """Benchmark stdlib UUID v4 generation""" |
39 | 36 | benchmark(lambda: uuid.uuid4()) |
40 | 37 |
|
41 | 38 |
|
42 | 39 | @pytest.mark.benchmark |
43 | 40 | def test_uuid4_utils(benchmark): |
44 | | - """Benchmark uuid_utils UUID v4 generation""" |
45 | 41 | benchmark(lambda: uuid_utils.uuid4()) |
46 | 42 |
|
47 | 43 |
|
48 | 44 | @pytest.mark.benchmark |
49 | 45 | def test_uuid5_stdlib(benchmark): |
50 | | - """Benchmark stdlib UUID v5 generation""" |
51 | 46 | benchmark(lambda: uuid.uuid5(namespace=uuid.NAMESPACE_DNS, name="python.org")) |
52 | 47 |
|
53 | 48 |
|
54 | 49 | @pytest.mark.benchmark |
55 | 50 | def test_uuid5_utils(benchmark): |
56 | | - """Benchmark uuid_utils UUID v5 generation""" |
57 | | - benchmark(lambda: uuid_utils.uuid5(namespace=uuid_utils.NAMESPACE_DNS, name="python.org")) |
| 51 | + benchmark( |
| 52 | + lambda: uuid_utils.uuid5(namespace=uuid_utils.NAMESPACE_DNS, name="python.org") |
| 53 | + ) |
58 | 54 |
|
59 | 55 |
|
60 | 56 | # UUID Parsing Benchmarks |
61 | 57 | @pytest.mark.benchmark |
62 | 58 | def test_uuid_from_hex_stdlib(benchmark): |
63 | | - """Benchmark stdlib UUID from hex string""" |
64 | 59 | benchmark(lambda: uuid.UUID("a8098c1a-f86e-11da-bd1a-00112444be1e")) |
65 | 60 |
|
66 | 61 |
|
67 | 62 | @pytest.mark.benchmark |
68 | 63 | def test_uuid_from_hex_utils(benchmark): |
69 | | - """Benchmark uuid_utils UUID from hex string""" |
70 | 64 | benchmark(lambda: uuid_utils.UUID("a8098c1a-f86e-11da-bd1a-00112444be1e")) |
71 | 65 |
|
72 | 66 |
|
73 | 67 | @pytest.mark.benchmark |
74 | 68 | def test_uuid_from_bytes_stdlib(benchmark): |
75 | | - """Benchmark stdlib UUID from bytes""" |
76 | 69 | hex_bytes = bytes.fromhex("a8098c1af86e11dabd1a00112444be1e") |
77 | 70 | benchmark(lambda: uuid.UUID(bytes=hex_bytes)) |
78 | 71 |
|
79 | 72 |
|
80 | 73 | @pytest.mark.benchmark |
81 | 74 | def test_uuid_from_bytes_utils(benchmark): |
82 | | - """Benchmark uuid_utils UUID from bytes""" |
83 | 75 | hex_bytes = bytes.fromhex("a8098c1af86e11dabd1a00112444be1e") |
84 | 76 | benchmark(lambda: uuid_utils.UUID(bytes=hex_bytes)) |
85 | 77 |
|
86 | 78 |
|
87 | 79 | @pytest.mark.benchmark |
88 | 80 | def test_uuid_from_int_stdlib(benchmark): |
89 | | - """Benchmark stdlib UUID from int""" |
90 | 81 | int_value = 223338299594506624080436508043913872926 |
91 | 82 | benchmark(lambda: uuid.UUID(int=int_value)) |
92 | 83 |
|
93 | 84 |
|
94 | 85 | @pytest.mark.benchmark |
95 | 86 | def test_uuid_from_int_utils(benchmark): |
96 | | - """Benchmark uuid_utils UUID from int""" |
97 | 87 | int_value = 223338299594506624080436508043913872926 |
98 | 88 | benchmark(lambda: uuid_utils.UUID(int=int_value)) |
99 | 89 |
|
100 | 90 |
|
101 | 91 | @pytest.mark.benchmark |
102 | 92 | def test_uuid_from_fields_stdlib(benchmark): |
103 | | - """Benchmark stdlib UUID from fields""" |
104 | 93 | benchmark(lambda: uuid.UUID(fields=(2819197978, 63598, 4570, 189, 26, 73622928926))) |
105 | 94 |
|
106 | 95 |
|
107 | 96 | @pytest.mark.benchmark |
108 | 97 | def test_uuid_from_fields_utils(benchmark): |
109 | | - """Benchmark uuid_utils UUID from fields""" |
110 | | - benchmark(lambda: uuid_utils.UUID(fields=(2819197978, 63598, 4570, 189, 26, 73622928926))) |
| 98 | + benchmark( |
| 99 | + lambda: uuid_utils.UUID(fields=(2819197978, 63598, 4570, 189, 26, 73622928926)) |
| 100 | + ) |
0 commit comments