Skip to content

Commit

Permalink
Add a benchmark of loading a certificate (#7551)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Aug 31, 2022
1 parent 69faea5 commit f9cf1cf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/bench/test_x509.py
Expand Up @@ -3,8 +3,12 @@
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.

import os

from cryptography import x509

from ..utils import load_vectors_from_file


def test_object_identier_constructor(benchmark):
benchmark(x509.ObjectIdentifier, "1.3.6.1.4.1.11129.2.4.5")
Expand All @@ -17,3 +21,13 @@ def test_aki_public_bytes(benchmark):
authority_cert_serial_number=None,
)
benchmark(aki.public_bytes)


def test_load_pem_certificate(benchmark):
cert_bytes = load_vectors_from_file(
os.path.join("x509", "cryptography.io.pem"),
loader=lambda pemfile: pemfile.read(),
mode="rb",
)

benchmark(x509.load_pem_x509_certificate, cert_bytes)

0 comments on commit f9cf1cf

Please sign in to comment.