8 Performance is compared between ``pyderasn==6.1``, ``pyasn1==0.4.8`` and
9 ``asn1crypto==1.3.0``. Decode CACert.org's CRL (2019-02-08 state, 8.72
10 MiB), encode it, pickle decoded structure and unpickle it. Machine is
11 Intel Core i5-6200U 2.3 GHz, 8 GB RAM, FreeBSD 12.0 amd64, Python 2.7.15
12 and Python 3.6.6 from native FreeBSD ports.
19 from pyasn1.codec.der.decoder import decode as der_decoder
20 from pyasn1.codec.der.encoder import encode as der_encoder
21 from pyasn1_modules.rfc5280 import CertificateList
22 with open("revoke.crl", "rb") as fd:
25 crl, _ = der_decoder(raw, asn1Spec=CertificateList())
26 print("decode", time() - start)
31 print("encode", time() - start)
32 # pyasn1 objects are not picklable
36 from asn1crypto.crl import CertificateList
37 with open("revoke.crl", "rb") as fd:
40 crl = CertificateList.load(raw)
41 c.native # full decoding and Python representation requires that
42 print("decode", time() - start)
46 crl.dump(force=True) # forced DER encoding
47 print("encode", time() - start)
49 raw = pickle.dumps(crl)
50 print("dumps", time() - start)
56 print("loads", time() - start)
60 from tests.test_crl import CertificateList
61 with open("revoke.crl", "rb") as fd:
64 crl = CertificateList().decod(raw)
65 print("decode", time() - start)
70 print("encode", time() - start)
72 raw = pickle.dumps(crl)
73 print("dumps", time() - start)
79 print("loads", time() - start)
81 Also there are `cythonized <https://cython.org/>`__ asn1crypto and
82 pyderasn versions, made using ``Cython==0.29.14``,
83 ``FreeBSD clang version 6.0.1 (tags/RELEASE_601/final 335540) (based on
84 LLVM 6.0.1)``, ``CFLAGS=-O2`` and Python 3 mode.
93 - Decode time, sec (Py36/Py27)
94 - Encode time, sec (Py36/Py27)
95 - Memory used, MiB (Py36/Py27)
104 * - cython asn1crypto
117 asn1crypto performs slightly better (with higher memory cost), but pay
118 attention that it contains **much** less data for all objects (like
119 offsets, sizes, etc) and it is not strict at all, passing possibly
120 invalid DER structures! Also there are plenty of other :ref:`features`
126 pyasn1 objects are not pickable.
132 - dumps time, sec (Py36/Py27)
133 - loads time, sec (Py36/Py27)
134 - Memory used, MiB (Py36/Py27)
135 - Size, MiB (Py36/Py27)