Skip to content
Performance benchmarks of Python, Numpy, etc. vs. other languages such as Matlab, Julia, Fortran.
Python Fortran CMake MATLAB Meson C Other
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github ci=>actions Oct 7, 2019
NASA_JulesKouatchou cleanup cmake Jan 14, 2019
archive ci=>actions Oct 7, 2019
cmake doc, cleanup CMake, notes to run with MSVC too Aug 15, 2019
iter cleanup Sep 13, 2018
mandelbrot cleanup Sep 13, 2018
matmul meson correct links syntax Oct 7, 2019
nonenan
pisum
power add power benchmarks Oct 7, 2019
pythonperformance meson OK Aug 15, 2019
tests plot title Aug 15, 2019
.coveragerc CI template, CuPy Aug 15, 2019
.flake8
.gitattributes CI template Aug 15, 2018
.gitignore functionalize Oct 17, 2018
CMakeLists.txt doc, cleanup CMake, notes to run with MSVC too Aug 15, 2019
LICENSE.txt CI template, CuPy Aug 15, 2019
Matmul.py meson OK Aug 15, 2019
Pisum.py plot title Aug 15, 2019
README.md
RunHypot.py black, update pisum cmake Aug 15, 2019
WindowsStderr.py black, update pisum cmake Aug 15, 2019
carriage_return.py black, update pisum cmake Aug 15, 2019
checkversions.py black, update pisum cmake Aug 15, 2019
dis_blank.c organize benchmarks into categories Jun 26, 2016
dis_div.c organize benchmarks into categories Jun 26, 2016
dis_mult.c
h5py_write_speed.py black, update pisum cmake Aug 15, 2019
hypot.f90 Squashed commit of the following: Mar 23, 2018
isoctave.m organize benchmarks into categories Jun 26, 2016
kind.f90 breakout matmul Feb 20, 2018
meson.build meson: better blas checking Oct 7, 2019
mypy.ini CI template, CuPy Aug 15, 2019
nans.py black, update pisum cmake Aug 15, 2019
netcdf_write_speed.py black, update pisum cmake Aug 15, 2019
no_traceback_error.py black, update pisum cmake Aug 15, 2019
perf.f90 pure Sep 13, 2018
pyproject.toml CI template, CuPy Aug 15, 2019
requirements.txt meson: better blas checking Oct 7, 2019
setup.cfg ci=>actions Oct 7, 2019
setup.py black, update pisum cmake Aug 15, 2019

README.md

Actions Status

Python Performance

All benchmarks are platform-independent (run on any computing device with appropriate hardware). CuPy tests require an NVIDIA GPU with CUDA toolkit installed.

Install

This command prepares Python prereqs:

pip install -e .

Using the C and/or Fortran tests requires compilation using CMake.

cmake -B build

cmake --build build --target test  # non-Visual Studio

cmake --build build --target RUN_TESTS  # Visual Studio

Usage

Iterative benchmarks, here using the pisum algorithm:

python Pisum.py

Pi (Machin) benchmark Windows 10

Pi (Machin) benchmark

Matrix Multiplication benchmarks:

python Matmul.py

Hypotenuse

Observe that hypot() is faster from 1 to a few hundred elements, then sqrt(x^2+y^2) becomes slightly faster. However, hypot() does not overflow for arguments near REALMAX. For example, in Python:

from math import sqrt, hypot

a=1e154; hypot(a,a); sqrt(a**2+a**2);

1.414213562373095e+154
inf

Execute the Hypot speed test by:

./RunHypot.py

Python 3.6 hypot() vs rsq()

Python 2.7 hypot() vs rsq()

Python 3.5 hypot() vs rsq()

Notes

Julia

Julia binaries are often downloaded to a particular directory. Python doesn't pickup .bash_aliases, which is commonly used to point to Julia.

Compiler selection

Intel Fortran:

FC=ifort cmake ..

GNU Fortran (gfortran ≥ 6 required):

FC=gfortran cmake ..

MKL selection

https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor

We give a hint to CMake where your MKL libraries on. For example:

MKLROOT=/opt/intel/mkl cmake ..

Of course this option can be combined with FC.

You can set this environment variable permanently for your convenience (normally you always want to use MKL) by adding to your ~/.bashrc the line:

export MKLROOT=/opt/intel/mkl
You can’t perform that action at this time.