.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_build/auto_examples/benchmarks/FFT_bench_scipy_backend.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_FFT_bench_scipy_backend.py: Benchmark of FFT implementations available as scipy backends ============================================================ .. GENERATED FROM PYTHON SOURCE LINES 7-10 This benchmark compares execution times of several FFT functions using different scipy backends. The plots give the measured execution time of the FFT as a function of the input length. The input length is of the form 3 * 5 * 2**i, so as to favor powers of 2 and small divisors. .. GENERATED FROM PYTHON SOURCE LINES 10-77 .. code-block:: Python def fft(x): scipy.fft.fft(x) def rfft(x): scipy.fft.rfft(x) def dct_I(x): N = x.shape[0] n = N // 2 + 1 scipy.fft.dct(x[:n],1) def dst_I(x): N = x.shape[0] n = N // 2 - 1 scipy.fft.dst(x[:n],1) def dct_III(x): N = x.shape[0] n = N // 4 scipy.fft.dct(x[:n],3) def dst_III(x): N = x.shape[0] n = N // 4 scipy.fft.dst(x[:n],3) all_args = { 'n' : np.array([4*3*5 * 2**n for n in range(15)]) , 'backend' : [backend_name for backend_name in all_backends] , } all_funs = [ # fft , rfft , # dct_I , # dst_I , # dct_III , # dst_III , ] n_repeat = 10 all_times = pyquickbench.run_benchmark( all_args , all_funs , setup = setup , n_repeat = n_repeat , filename = timings_filename , title = 'Absolute timings' , ) plot_intent = { 'n' : 'points' , 'backend' : 'subplot_grid_y', } pyquickbench.plot_benchmark( all_times , all_args , all_funs , show = True , plot_intent = plot_intent , ) .. image-sg:: /_build/auto_examples/benchmarks/images/sphx_glr_FFT_bench_scipy_backend_001.png :alt: backend : scipy, backend : MKL :srcset: /_build/auto_examples/benchmarks/images/sphx_glr_FFT_bench_scipy_backend_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 152-167 .. code-block:: Python relative_to_val = { 'backend' : 'MKL' , pyquickbench.fun_ax_name : "rfft" , } pyquickbench.plot_benchmark( all_times , all_args , all_funs , show = True , plot_intent = plot_intent , relative_to_val = relative_to_val , title = 'Relative timings wrt MKL fft' , ) .. image-sg:: /_build/auto_examples/benchmarks/images/sphx_glr_FFT_bench_scipy_backend_002.png :alt: Relative timings wrt MKL fft, backend : scipy, backend : MKL :srcset: /_build/auto_examples/benchmarks/images/sphx_glr_FFT_bench_scipy_backend_002.png :class: sphx-glr-single-img .. _sphx_glr_download__build_auto_examples_benchmarks_FFT_bench_scipy_backend.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: FFT_bench_scipy_backend.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: FFT_bench_scipy_backend.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: FFT_bench_scipy_backend.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_