prestissimo speed Docs Editor CPU vs GPU

Four languages, three kernels

200000 elements, best of 7, in one process through ctypes. Log axis.

Nanoseconds per element, lower is better 200000 elements, best of 7, in one process through ctypes. Log axis. 0.1 1 10 100 saxpy y = a*x + y pure Python 37.79 NumPy 0.29 129x C, restrict 0.13 300x magnitude sqrt(ax^2 + ay^2) pure Python 76.75 NumPy 1.31 59x C, restrict 0.34 227x poly five chained multiply-adds pure Python 72.96 NumPy 1.13 64x C, restrict 0.14 534x
kernelpure Python (ns)NumPy (ns)C, restrict (ns)
saxpy y = a*x + y37.790.290.13
magnitude sqrt(ax^2 + ay^2)76.751.310.34
poly five chained multiply-adds72.961.130.14

How this was measured

Everything ran in one process on the same arrays. Pure Python and NumPy ran directly. C and Prestissimo were built into shared libraries and called through ctypes, which is how a real program would call them. Each figure is the best of 7 runs.

The axis is logarithmic because the range spans about four orders of magnitude. On a linear axis every compiled bar would be a single pixel.

What it does and does not show

The gap between Python and the compiled languages is the cost of an interpreter, and it is not news. The interesting comparison is the one between the last two bars, which are usually within a few percent of each other: both go through the same LLVM back end, so parity is the ceiling rather than a disappointment.

NumPy sits between them. It runs the same vector instructions, but pays for a pass over memory per operation rather than fusing the whole expression into one pass, which is why the gap widens on poly.

Timings on a desktop vary by tens of percent between runs. Read the orders of magnitude, not the last digit.