.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_benchmark_dot.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_auto_examples_plot_benchmark_dot.py: .. _l-example-dot: Compares dot implementations (numpy, python, blas) ================================================== :epkg:`numpy` has a very fast implementation of the dot product. It is difficult to be better and very easy to be slower. This example looks into a couple of slower implementations. Compared implementations: * :func:`pydot ` * `cblas_ddot `_ .. contents:: :local: .. GENERATED FROM PYTHON SOURCE LINES 22-30 .. code-block:: default import pprint import numpy import matplotlib.pyplot as plt from pandas import DataFrame, concat from td3a_cpp.tutorial import pydot, cblas_ddot from td3a_cpp.tools import measure_time_dim .. GENERATED FROM PYTHON SOURCE LINES 31-37 python dot: pydot +++++++++++++++++ The first function :func:`pydot ` uses python to implement the dot product. .. GENERATED FROM PYTHON SOURCE LINES 37-48 .. code-block:: default ctxs = [dict(va=numpy.random.randn(n).astype(numpy.float64), vb=numpy.random.randn(n).astype(numpy.float64), pydot=pydot, x_name=n) for n in range(10, 1000, 100)] res_pydot = list(measure_time_dim('pydot(va, vb)', ctxs, verbose=1)) pprint.pprint(res_pydot[:2]) .. rst-class:: sphx-glr-script-out .. code-block:: none 0%| | 0/10 [00:00` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_benchmark_dot.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_