{ "cells": [ { "attachments": {}, "cell_type": "markdown", "id": "96d52364-7a21-4cab-ad30-0f0144667563", "metadata": {}, "source": [ "# Performances of 2D integration vs 1D integration\n", "\n", "This is dependent on:\n", "* Number of azimuthal bins\n", "* Pixel splitting\n", "* Algorithm\n", "* Implementation (i.e. programming language)\n", "* Hardware used\n", "\n", "Thus there is no general answer. But here is a quick benchmark to evaluate the penalty on performances:\n", "\n", "import sys\n", "import os\n", "import time\n", "import numpy\n", "import fabio\n", "import pyFAI\n", "from pyFAI.test.utilstest import UtilsTest\n", "import pyFAI.method_registry\n", "import pyFAI.integrator.azimuthal\n", "print(f\"Python version: {sys.version}\")\n", "print(f\"PyFAI version: {pyFAI.version}\")\n", "start_time = time.perf_counter()" ] }, { "cell_type": "code", "execution_count": 1, "id": "332f573a-e5b6-4865-aff7-def54aa54faa", "metadata": { "execution": { "iopub.execute_input": "2026-09-15T09:14:55.762480Z", "iopub.status.busy": "2026-09-15T09:14:55.762403Z", "iopub.status.idle": "2026-09-15T09:14:55.766145Z", "shell.execute_reply": "2026-09-15T09:14:55.765588Z" } }, "outputs": [], "source": [ "import sys\n", "import os\n", "import time\n", "\n", "os.environ[\"PYOPENCL_COMPILER_OUTPUT\"] = \"0\"\n", "start_time = time.perf_counter()" ] }, { "cell_type": "code", "execution_count": 2, "id": "367b3b78-04d9-4f47-85e5-0f11c4383a70", "metadata": { "execution": { "iopub.execute_input": "2026-09-15T09:14:55.767722Z", "iopub.status.busy": "2026-09-15T09:14:55.767590Z", "iopub.status.idle": "2026-09-15T09:14:57.044381Z", "shell.execute_reply": "2026-09-15T09:14:57.043588Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Python version: 3.13.1 | packaged by conda-forge | (main, Jan 13 2025, 09:53:10) [GCC 13.3.0]\n", "PyFAI version: 2026.9.0\n" ] } ], "source": [ "import fabio\n", "import pyFAI\n", "from pyFAI.test.utilstest import UtilsTest\n", "import pyFAI.method_registry\n", "import pyFAI.integrator.azimuthal\n", "print(f\"Python version: {sys.version}\")\n", "print(f\"PyFAI version: {pyFAI.version}\")\n" ] }, { "cell_type": "code", "execution_count": 3, "id": "b3a6bd65-9b17-4c20-ad4a-870242eeed1b", "metadata": { "execution": { "iopub.execute_input": "2026-09-15T09:14:57.046884Z", "iopub.status.busy": "2026-09-15T09:14:57.046646Z", "iopub.status.idle": "2026-09-15T09:14:57.049677Z", "shell.execute_reply": "2026-09-15T09:14:57.048996Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of way to performing integration: 95\n" ] } ], "source": [ "print(\"Number of way to performing integration:\", len(pyFAI.method_registry.IntegrationMethod.list_available()))" ] }, { "cell_type": "code", "execution_count": 4, "id": "1479c126-f758-42e0-9209-3c6af91ada5a", "metadata": { "execution": { "iopub.execute_input": "2026-09-15T09:14:57.051284Z", "iopub.status.busy": "2026-09-15T09:14:57.051193Z", "iopub.status.idle": "2026-09-15T09:14:57.115627Z", "shell.execute_reply": "2026-09-15T09:14:57.114981Z" } }, "outputs": [ { "data": { "text/plain": [ "Detector Pilatus 1M\t PixelSize= 172µm, 172µm\t BottomRight (3)\n", "Wavelength= 1.000000 Å\n", "SampleDetDist= 1.583231e+00 m\tPONI= 3.341702e-02, 4.122778e-02 m\trot1=0.006487 rot2=0.007558 rot3=0.000000 rad\n", "DirectBeamDist= 1583.310 mm\tCenter: x=179.981, y=263.859 pix\tTilt= 0.571° tiltPlanRotation= 130.640° λ= 1.000Å" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ai = pyFAI.load(UtilsTest.getimage(\"Pilatus1M.poni\"))\n", "img = fabio.open(UtilsTest.getimage(\"Pilatus1M.edf\")).data\n", "ai" ] }, { "cell_type": "code", "execution_count": 5, "id": "aea1ab6d-afc5-4152-a60b-8b25dc7d460b", "metadata": { "execution": { "iopub.execute_input": "2026-09-15T09:14:57.117610Z", "iopub.status.busy": "2026-09-15T09:14:57.117513Z", "iopub.status.idle": "2026-09-15T09:22:35.396739Z", "shell.execute_reply": "2026-09-15T09:22:35.395919Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Method(dim=1, split='no', algo='histogram', impl='python', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "30.6 ms ± 109 μs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n", "Method(dim=2, split='no', algo='histogram', impl='python', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "123 ms ± 501 μs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n", "Method(dim=1, split='no', algo='histogram', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "11.3 ms ± 48.2 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='no', algo='histogram', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "16.5 ms ± 137 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=1, split='bbox', algo='histogram', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "26.7 ms ± 49.1 μs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n", "Method(dim=2, split='bbox', algo='histogram', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "33.1 ms ± 86.2 μs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n", "Method(dim=1, split='full', algo='histogram', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "140 ms ± 930 μs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n", "Method(dim=2, split='full', algo='histogram', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "268 ms ± 1.29 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=2, split='pseudo', algo='histogram', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "346 ms ± 2.27 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='no', algo='csr', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "11.4 ms ± 1.17 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='no', algo='csr', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "11.4 ms ± 474 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=1, split='bbox', algo='csr', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "12 ms ± 996 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='bbox', algo='csr', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "14.3 ms ± 714 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=1, split='no', algo='csr', impl='python', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "10.1 ms ± 158 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='no', algo='csr', impl='python', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "14.3 ms ± 58.3 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=1, split='bbox', algo='csr', impl='python', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "13.2 ms ± 33.3 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='bbox', algo='csr', impl='python', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "20.7 ms ± 1.29 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=1, split='no', algo='csc', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "6.97 ms ± 4.57 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='no', algo='csc', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "9.77 ms ± 59.9 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=1, split='bbox', algo='csc', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "9.05 ms ± 15.1 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='bbox', algo='csc', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "12.7 ms ± 46.7 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=1, split='no', algo='csc', impl='python', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "11 ms ± 46.5 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='no', algo='csc', impl='python', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "14.3 ms ± 17.7 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=1, split='bbox', algo='csc', impl='python', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "14.8 ms ± 11.4 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='bbox', algo='csc', impl='python', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "22 ms ± 34.5 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='bbox', algo='lut', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "11.9 ms ± 782 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='bbox', algo='lut', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "17.8 ms ± 2.65 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='no', algo='lut', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "12 ms ± 1.17 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='no', algo='lut', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "16.2 ms ± 1.66 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='full', algo='lut', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "15.9 ms ± 1.17 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=2, split='full', algo='lut', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "15.5 ms ± 3.36 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='full', algo='csr', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "11.2 ms ± 1.27 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='full', algo='csr', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "16 ms ± 1.61 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='full', algo='csr', impl='python', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "12.8 ms ± 24.3 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='full', algo='csr', impl='python', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "16.7 ms ± 33.3 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='full', algo='csc', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "9.39 ms ± 11.5 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=2, split='full', algo='csc', impl='cython', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "13.1 ms ± 94.4 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='full', algo='csc', impl='python', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "15.1 ms ± 20.2 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='full', algo='csc', impl='python', target=None)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "21.7 ms ± 40 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='no', algo='histogram', impl='opencl', target=(0, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "8.96 ms ± 13.4 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='no', algo='histogram', impl='opencl', target=(0, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "2.73 ms ± 11.2 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=1, split='no', algo='histogram', impl='opencl', target=(0, 1))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "8.45 ms ± 47.6 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='no', algo='histogram', impl='opencl', target=(0, 1))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "4.17 ms ± 11 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=1, split='no', algo='histogram', impl='opencl', target=(1, 0))\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "1 error generated.\n", "WARNING:pyFAI.opencl.azim_hist:Your OpenCL compiler wrongly claims it support 64-bit atomics. Degrading to 32 bits atomics!\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "15.5 ms ± 1.46 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=2, split='no', algo='histogram', impl='opencl', target=(1, 0))\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "1 error generated.\n", "WARNING:pyFAI.opencl.azim_hist:Your OpenCL compiler wrongly claims it support 64-bit atomics. Degrading to 32 bits atomics!\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "10.2 ms ± 2.07 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='no', algo='histogram', impl='opencl', target=(2, 0))\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/users/kieffer/.venv/py313/lib/python3.13/site-packages/pyopencl/cache.py:445: CompilerWarning: Non-empty compiler output encountered. Set the environment variable PYOPENCL_COMPILER_OUTPUT=1 to see more.\n", " prg.build(options_bytes, [devices[i] for i in to_be_built_indices])\n", "WARNING:pyFAI.opencl.azim_hist:Your OpenCL compiler wrongly claims it support 64-bit atomics. Degrading to 32 bits atomics!\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "12.4 ms ± 1.45 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=2, split='no', algo='histogram', impl='opencl', target=(2, 0))\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "WARNING:pyFAI.opencl.azim_hist:Your OpenCL compiler wrongly claims it support 64-bit atomics. Degrading to 32 bits atomics!\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "7.34 ms ± 2.56 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='bbox', algo='csr', impl='opencl', target=(0, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "704 μs ± 1.29 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n", "Method(dim=2, split='bbox', algo='csr', impl='opencl', target=(0, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "2.6 ms ± 79.6 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='no', algo='csr', impl='opencl', target=(0, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "661 μs ± 2.48 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n", "Method(dim=2, split='no', algo='csr', impl='opencl', target=(0, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "2.32 ms ± 1.63 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=1, split='bbox', algo='csr', impl='opencl', target=(0, 1))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "1.22 ms ± 2.07 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n", "Method(dim=2, split='bbox', algo='csr', impl='opencl', target=(0, 1))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "6.13 ms ± 72.6 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='no', algo='csr', impl='opencl', target=(0, 1))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "1.09 ms ± 3.89 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n", "Method(dim=2, split='no', algo='csr', impl='opencl', target=(0, 1))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "5.99 ms ± 2.35 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=1, split='bbox', algo='csr', impl='opencl', target=(1, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "3.54 ms ± 16.9 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='bbox', algo='csr', impl='opencl', target=(1, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "8.69 ms ± 612 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='no', algo='csr', impl='opencl', target=(1, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "3.07 ms ± 12.7 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='no', algo='csr', impl='opencl', target=(1, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "6.27 ms ± 206 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=1, split='bbox', algo='csr', impl='opencl', target=(2, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "3.64 ms ± 145 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=2, split='bbox', algo='csr', impl='opencl', target=(2, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "84.5 ms ± 2.23 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='no', algo='csr', impl='opencl', target=(2, 0))\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/users/kieffer/.venv/py313/lib/python3.13/site-packages/pyopencl/cache.py:527: CompilerWarning: Non-empty compiler output encountered. Set the environment variable PYOPENCL_COMPILER_OUTPUT=1 to see more.\n", " _create_built_program_from_source_cached(\n", "/users/kieffer/.venv/py313/lib/python3.13/site-packages/pyopencl/cache.py:531: CompilerWarning: Non-empty compiler output encountered. Set the environment variable PYOPENCL_COMPILER_OUTPUT=1 to see more.\n", " prg.build(options_bytes, devices)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "2.75 ms ± 387 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=2, split='no', algo='csr', impl='opencl', target=(2, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "84.6 ms ± 2.94 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='full', algo='csr', impl='opencl', target=(0, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "711 μs ± 1.99 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n", "Method(dim=2, split='full', algo='csr', impl='opencl', target=(0, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "2.57 ms ± 77.5 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='full', algo='csr', impl='opencl', target=(0, 1))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "1.22 ms ± 858 ns per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n", "Method(dim=2, split='full', algo='csr', impl='opencl', target=(0, 1))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "6.08 ms ± 47.5 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='full', algo='csr', impl='opencl', target=(1, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "4.26 ms ± 23.3 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='full', algo='csr', impl='opencl', target=(1, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "9.25 ms ± 554 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='full', algo='csr', impl='opencl', target=(2, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "3.9 ms ± 366 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=2, split='full', algo='csr', impl='opencl', target=(2, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "84.5 ms ± 1.05 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='bbox', algo='lut', impl='opencl', target=(0, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "3.18 ms ± 11.2 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='bbox', algo='lut', impl='opencl', target=(0, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "443 ms ± 13.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='no', algo='lut', impl='opencl', target=(0, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "1.6 ms ± 6.56 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n", "Method(dim=2, split='no', algo='lut', impl='opencl', target=(0, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "268 ms ± 6.25 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='bbox', algo='lut', impl='opencl', target=(0, 1))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "3.15 ms ± 2.78 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='bbox', algo='lut', impl='opencl', target=(0, 1))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "554 ms ± 7.37 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='no', algo='lut', impl='opencl', target=(0, 1))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "1.82 ms ± 2.55 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n", "Method(dim=2, split='no', algo='lut', impl='opencl', target=(0, 1))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "246 ms ± 5.28 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='bbox', algo='lut', impl='opencl', target=(1, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "4.76 ms ± 62.9 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='bbox', algo='lut', impl='opencl', target=(1, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "378 ms ± 50 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='no', algo='lut', impl='opencl', target=(1, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "3.71 ms ± 52.9 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='no', algo='lut', impl='opencl', target=(1, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "257 ms ± 23.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='bbox', algo='lut', impl='opencl', target=(2, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "4.66 ms ± 417 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=2, split='bbox', algo='lut', impl='opencl', target=(2, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "259 ms ± 7.88 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='no', algo='lut', impl='opencl', target=(2, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "3.33 ms ± 144 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=2, split='no', algo='lut', impl='opencl', target=(2, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "256 ms ± 50.5 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='full', algo='lut', impl='opencl', target=(0, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "2.59 ms ± 2 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='full', algo='lut', impl='opencl', target=(0, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "555 ms ± 4.82 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='full', algo='lut', impl='opencl', target=(0, 1))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "2.78 ms ± 155 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='full', algo='lut', impl='opencl', target=(0, 1))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "529 ms ± 2.25 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='full', algo='lut', impl='opencl', target=(1, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "4.77 ms ± 88.8 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "Method(dim=2, split='full', algo='lut', impl='opencl', target=(1, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "336 ms ± 32.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=1, split='full', algo='lut', impl='opencl', target=(2, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "5.12 ms ± 342 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "Method(dim=2, split='full', algo='lut', impl='opencl', target=(2, 0))\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "428 ms ± 51.1 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", "CPU times: user 1h 24min 6s, sys: 2min 28s, total: 1h 26min 34s\n", "Wall time: 7min 38s\n" ] } ], "source": [ "%%time\n", "#Tune those parameters to match your needs:\n", "kw1 = {\"data\": img, \"npt\":1000}\n", "kw2 = {\"data\": img, \"npt_rad\":1000}\n", "#Actual benchmark:\n", "res = {}\n", "for k,v in pyFAI.method_registry.IntegrationMethod._registry.items():\n", " print(k)\n", " if k.dim == 1:\n", " res[k] = %timeit -o ai.integrate1d(method=v, **kw1)\n", " else:\n", " res[k] = %timeit -o ai.integrate2d(method=v, **kw2)" ] }, { "cell_type": "code", "execution_count": 6, "id": "cf37152a-27df-4105-a372-7d8d21366fc7", "metadata": { "execution": { "iopub.execute_input": "2026-09-15T09:22:35.398677Z", "iopub.status.busy": "2026-09-15T09:22:35.398580Z", "iopub.status.idle": "2026-09-15T09:22:35.403303Z", "shell.execute_reply": "2026-09-15T09:22:35.402631Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--------------------------------------------------------------------------------\n", "Split | Algo | Impl | 1d (ms) | 2d (ms) | ratio | Device\n", "--------------------------------------------------------------------------------\n", "no | histogram | python| 30.506 | 122.610 | 4.0 | \n", "no | histogram | cython| 11.235 | 16.283 | 1.4 | \n", "bbox | histogram | cython| 26.663 | 33.054 | 1.2 | \n", "full | histogram | cython| 138.818 | 265.720 | 1.9 | \n", "no | csr | cython| 9.326 | 10.673 | 1.1 | \n", "bbox | csr | cython| 10.563 | 12.923 | 1.2 | \n", "no | csr | python| 9.894 | 14.225 | 1.4 | \n", "bbox | csr | python| 13.196 | 17.687 | 1.3 | \n", "no | csc | cython| 6.966 | 9.718 | 1.4 | \n", "bbox | csc | cython| 9.033 | 12.614 | 1.4 | \n", "no | csc | python| 10.950 | 14.282 | 1.3 | \n", "bbox | csc | python| 14.823 | 21.925 | 1.5 | \n", "bbox | lut | cython| 10.894 | 12.191 | 1.1 | \n", "no | lut | cython| 9.405 | 14.122 | 1.5 | \n", "full | lut | cython| 13.995 | 11.820 | 0.8 | \n", "full | csr | cython| 9.079 | 13.611 | 1.5 | \n", "full | csr | python| 12.763 | 16.640 | 1.3 | \n", "full | csc | cython| 9.370 | 12.954 | 1.4 | \n", "full | csc | python| 15.076 | 21.606 | 1.4 | \n", "no | histogram | opencl| 8.944 | 2.713 | 0.3 | NVIDIA CUDA / NVIDIA RTX A5000\n", "no | histogram | opencl| 8.397 | 4.157 | 0.5 | NVIDIA CUDA / Quadro P2200\n", "no | histogram | opencl| 14.474 | 8.737 | 0.6 | Portable Computing Language / cpu-haswell-AMD Ryzen Threadripper PRO 3975WX 32-Cores\n", "no | histogram | opencl| 10.671 | 5.639 | 0.5 | Intel(R) OpenCL / AMD Ryzen Threadripper PRO 3975WX 32-Cores\n", "bbox | csr | opencl| 0.702 | 2.556 | 3.6 | NVIDIA CUDA / NVIDIA RTX A5000\n", "no | csr | opencl| 0.660 | 2.317 | 3.5 | NVIDIA CUDA / NVIDIA RTX A5000\n", "bbox | csr | opencl| 1.219 | 6.079 | 5.0 | NVIDIA CUDA / Quadro P2200\n", "no | csr | opencl| 1.081 | 5.990 | 5.5 | NVIDIA CUDA / Quadro P2200\n", "bbox | csr | opencl| 3.512 | 7.983 | 2.3 | Portable Computing Language / cpu-haswell-AMD Ryzen Threadripper PRO 3975WX 32-Cores\n", "no | csr | opencl| 3.053 | 6.065 | 2.0 | Portable Computing Language / cpu-haswell-AMD Ryzen Threadripper PRO 3975WX 32-Cores\n", "bbox | csr | opencl| 3.505 | 83.285 | 23.8 | Intel(R) OpenCL / AMD Ryzen Threadripper PRO 3975WX 32-Cores\n", "no | csr | opencl| 2.368 | 82.595 | 34.9 | Intel(R) OpenCL / AMD Ryzen Threadripper PRO 3975WX 32-Cores\n", "full | csr | opencl| 0.710 | 2.531 | 3.6 | NVIDIA CUDA / NVIDIA RTX A5000\n", "full | csr | opencl| 1.223 | 6.052 | 4.9 | NVIDIA CUDA / Quadro P2200\n", "full | csr | opencl| 4.230 | 8.486 | 2.0 | Portable Computing Language / cpu-haswell-AMD Ryzen Threadripper PRO 3975WX 32-Cores\n", "full | csr | opencl| 3.575 | 83.714 | 23.4 | Intel(R) OpenCL / AMD Ryzen Threadripper PRO 3975WX 32-Cores\n", "bbox | lut | opencl| 3.166 | 425.986 | 134.6 | NVIDIA CUDA / NVIDIA RTX A5000\n", "no | lut | opencl| 1.597 | 255.142 | 159.8 | NVIDIA CUDA / NVIDIA RTX A5000\n", "bbox | lut | opencl| 3.148 | 548.202 | 174.1 | NVIDIA CUDA / Quadro P2200\n", "no | lut | opencl| 1.815 | 241.674 | 133.1 | NVIDIA CUDA / Quadro P2200\n", "bbox | lut | opencl| 4.651 | 328.324 | 70.6 | Portable Computing Language / cpu-haswell-AMD Ryzen Threadripper PRO 3975WX 32-Cores\n", "no | lut | opencl| 3.601 | 223.489 | 62.1 | Portable Computing Language / cpu-haswell-AMD Ryzen Threadripper PRO 3975WX 32-Cores\n", "bbox | lut | opencl| 3.773 | 251.532 | 66.7 | Intel(R) OpenCL / AMD Ryzen Threadripper PRO 3975WX 32-Cores\n", "no | lut | opencl| 3.151 | 205.475 | 65.2 | Intel(R) OpenCL / AMD Ryzen Threadripper PRO 3975WX 32-Cores\n", "full | lut | opencl| 2.590 | 548.720 | 211.9 | NVIDIA CUDA / NVIDIA RTX A5000\n", "full | lut | opencl| 2.706 | 523.917 | 193.6 | NVIDIA CUDA / Quadro P2200\n", "full | lut | opencl| 4.595 | 297.045 | 64.6 | Portable Computing Language / cpu-haswell-AMD Ryzen Threadripper PRO 3975WX 32-Cores\n", "full | lut | opencl| 4.857 | 349.008 | 71.9 | Intel(R) OpenCL / AMD Ryzen Threadripper PRO 3975WX 32-Cores\n", "--------------------------------------------------------------------------------\n" ] } ], "source": [ "print(\"-\"*80)\n", "print(f\"{'Split':5s} | {'Algo':9s} | {'Impl':6s}| {'1d (ms)':8s} | {'2d (ms)':8s} | {'ratio':6s} | Device\")\n", "print(\"-\"*80)\n", "for k in res:\n", " if k.dim == 1:\n", " k1 = k\n", " k2 = k._replace(dim=2)\n", " if k2 in res:\n", " print(f\"{k1.split:5s} | {k1.algo:9s} | {k1.impl:6s}| {res[k1].best*1000:8.3f} | {res[k2].best*1000:8.3f} | {res[k2].best/res[k1].best:6.1f} | \",\n", " end=\"\")\n", " if k.target:\n", " print(pyFAI.method_registry.IntegrationMethod._registry.get(k).target_name)\n", " else:\n", " print()\n", "print(\"-\"*80)" ] }, { "cell_type": "code", "execution_count": 7, "id": "4d1e3ab4-aabd-4429-b1b2-818eb1f386a9", "metadata": { "execution": { "iopub.execute_input": "2026-09-15T09:22:35.404908Z", "iopub.status.busy": "2026-09-15T09:22:35.404819Z", "iopub.status.idle": "2026-09-15T09:22:35.407390Z", "shell.execute_reply": "2026-09-15T09:22:35.406761Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Total runtime: 459.641s\n" ] } ], "source": [ "print(f\"Total runtime: {time.perf_counter()-start_time:.3f}s\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.1" } }, "nbformat": 4, "nbformat_minor": 5 }