Metadata-Version: 2.4
Name: mandelbrot-benchmark
Version: 1.2.0
Summary: Benchmark Numba, Taichi, Warp, CuPy Kernel, Triton using Mandelbrot set
Author: 34j
License-Expression: MIT
Project-URL: Bug Tracker, https://github.com/34j/mandelbrot-benchmark/issues
Project-URL: Changelog, https://github.com/34j/mandelbrot-benchmark/blob/main/CHANGELOG.md
Project-URL: documentation, https://mandelbrot-benchmark.readthedocs.io
Project-URL: repository, https://github.com/34j/mandelbrot-benchmark
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Requires-Python: <3.14,>=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aquarel>=0.0.7
Requires-Dist: array-api-compat>=1.11.2
Requires-Dist: cm-time>=0.1.2
Requires-Dist: jax>=0.4.30; sys_platform != "linux"
Requires-Dist: jax[cuda12]>=0.4.30; sys_platform == "linux"
Requires-Dist: matplotlib>=3.9.4
Requires-Dist: numba>=0.60
Requires-Dist: numpy<=2.3.4
Requires-Dist: pandas>=2.3.1
Requires-Dist: pydlpack>=0.2.1
Requires-Dist: rich>=10
Requires-Dist: seaborn>=0.13.2
Requires-Dist: taichi>=1.7.4
Requires-Dist: torch>=2.8
Requires-Dist: tqdm>=4.67.1
Requires-Dist: typer<1,>=0.15
Requires-Dist: warp-lang>=1.8.1
Dynamic: license-file

# mandelbrot-benchmark

<p align="center">
  <a href="https://github.com/34j/mandelbrot-benchmark/actions/workflows/ci.yml?query=branch%3Amain">
    <img src="https://img.shields.io/github/actions/workflow/status/34j/mandelbrot-benchmark/ci.yml?branch=main&label=CI&logo=github&style=flat-square" alt="CI Status" >
  </a>
  <a href="https://mandelbrot-benchmark.readthedocs.io">
    <img src="https://img.shields.io/readthedocs/mandelbrot-benchmark.svg?logo=read-the-docs&logoColor=fff&style=flat-square" alt="Documentation Status">
  </a>
</p>
<p align="center">
  <a href="https://codecov.io/gh/34j/mandelbrot-benchmark">
    <img src="https://img.shields.io/codecov/c/github/34j/mandelbrot-benchmark.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">
  </a>
  <a href="https://github.com/astral-sh/uv">
    <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json" alt="uv">
  </a>
  <a href="https://github.com/astral-sh/ruff">
    <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
  </a>
  <a href="https://github.com/j178/prek">
    <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/j178/prek/master/docs/assets/badge-v0.json" alt="prek">
  </a>
</p>
<p align="center">
  <a href="https://pypi.org/project/mandelbrot-benchmark/">
    <img src="https://img.shields.io/pypi/v/mandelbrot-benchmark.svg?logo=python&logoColor=fff&style=flat-square" alt="PyPI Version">
  </a>
  <img src="https://img.shields.io/pypi/pyversions/mandelbrot-benchmark.svg?style=flat-square&logo=python&amp;logoColor=fff" alt="Supported Python versions">
  <img src="https://img.shields.io/pypi/l/mandelbrot-benchmark.svg?style=flat-square" alt="License">
</p>

---

**Documentation**: <a href="https://mandelbrot-benchmark.readthedocs.io" target="_blank">https://mandelbrot-benchmark.readthedocs.io </a>

**Source Code**: <a href="https://github.com/34j/mandelbrot-benchmark" target="_blank">https://github.com/34j/mandelbrot-benchmark </a>

---

Benchmark Numba, Taichi, Warp, CuPy Kernel, Triton using Mandelbrot set

## Results

- 200 iterations max
- $c \in [-2, 1] \times [-1.5, 1.5]$
- JAX version is quite hacky ("vectorized")
- `JAX` version is omitted because it makes the benchmark unstable (see previous release for the comparison)
- AMD Ryzen 9 3950X + NVIDIA GeForce RTX 4070 SUPER

![Results](https://raw.githubusercontent.com/34j/mandelbrot-benchmark/main/results.png)

- The results are almost identical when `device = cuda`
- The computation time for `Numba` is quite unstable

![Mandelbrot Set](https://raw.githubusercontent.com/34j/mandelbrot-benchmark/main/test_plot.png)

## Some notes

- In `Numba`, the type of variables needs to be explicitly specified to use `float32` instead of `float64` (default), while is not the case for `Taichi`, `Warp`.

## Installation

Install this via pip (or your favourite package manager):

```shell
pipx install mandelbrot-benchmark
```

## Usage

Run the benchmark and plot the results:

```shell
mandelbrot-benchmark benchmark
mandelbrot-benchmark plot
```

## Alternatives

- [YanagiAyame/python-mandelbrot-benchmark: Which is better, Numba, Taichi, Warp or JAX?](https://github.com/YanagiAyame/python-mandelbrot-benchmark)
- [mandelbrot-on-all-accelerators.ipynb](https://gist.github.com/jpivarski/da343abd8024834ee8c5aaba691aafc7)
