.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_build/auto_examples/benchmarks/Hashing.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__build_auto_examples_benchmarks_Hashing.py: Time benchmark of built-in hashing in Python ============================================ .. GENERATED FROM PYTHON SOURCE LINES 7-8 This is a benchmark of different ways to perform inplace conjugation of a complex numpy array. .. GENERATED FROM PYTHON SOURCE LINES 9-85 .. code-block:: Python import random import pyquickbench def randbytes(n): return {'data':random.randbytes(n)} import hashlib def md5(data): return hashlib.md5(data) def sha1(data): return hashlib.sha1(data) def sha224(data): return hashlib.sha224(data) def sha256(data): return hashlib.sha256(data) def sha384(data): return hashlib.sha384(data) def sha512(data): return hashlib.sha512(data) def sha3_224(data): return hashlib.sha3_224(data) def sha3_256(data): return hashlib.sha3_256(data) def sha3_384(data): return hashlib.sha3_384(data) def sha3_512(data): return hashlib.sha3_512(data) all_funs = [ md5 , sha1 , sha224 , sha256 , sha384 , sha512 , sha3_224 , sha3_256 , sha3_384 , sha3_512 , ] all_sizes = [2**n for n in range(25)] basename = 'Hashing_bench' timings_filename = os.path.join(timings_folder, basename+'.npz') n_repeat = 1 all_values = pyquickbench.run_benchmark( all_sizes , all_funs , setup = randbytes , n_repeat = n_repeat , filename = timings_filename , ShowProgress=True , ) pyquickbench.plot_benchmark( all_values , all_sizes , all_funs , show = True , title = 'Built-in hashing in Python' , ) .. image-sg:: /_build/auto_examples/benchmarks/images/sphx_glr_Hashing_001.png :alt: Built-in hashing in Python :srcset: /_build/auto_examples/benchmarks/images/sphx_glr_Hashing_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 116-130 .. code-block:: Python relative_to_val = {pyquickbench.fun_ax_name:"sha1"} pyquickbench.plot_benchmark( all_values , all_sizes , all_funs , relative_to_val = relative_to_val , show = True , title = 'Built-in hashing in Python' , ylabel = 'Time relative to sha1' , ) .. image-sg:: /_build/auto_examples/benchmarks/images/sphx_glr_Hashing_002.png :alt: Built-in hashing in Python :srcset: /_build/auto_examples/benchmarks/images/sphx_glr_Hashing_002.png :class: sphx-glr-single-img .. _sphx_glr_download__build_auto_examples_benchmarks_Hashing.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Hashing.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Hashing.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: Hashing.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_