13

I've been benchmarking the Pi on some of my simulation codes, relative to a couple of laptops I have. My codes tend to be floating point intensive, so I've been using Raspbian (which turns out to be much faster) due to its hard-float support. I have the same simple code in several different languages. Obviously python code is slower than C code whatever platform I use, but on the Pi it appears to be relatively more slow, by a factor of around 3. Does anyone know why the python interpreter is likely to be relatively slow on the Pi, and is this something that is likely to be fixed?

Here is the test:

import random,math

def gibbs(N=50000,thin=1000):
    x=0
    y=0
    print "Iter  x  y"
    for i in range(N):
        for j in range(thin):
            x=random.gammavariate(3,1.0/(y*y+4))
            y=random.gauss(1.0/(x+1),1.0/math.sqrt(2*x+2))
        print i,x,y

gibbs()

From this blog post about the experiment.

Darren Wilkinson
  • 2,922
  • 4
  • 28
  • 27

2 Answers2

7

I would guess that the Python interpreter is simply not optimized for ARM. Python might have been optimized for the other platforms. In my experience, this is true for software like OpenSSH, so I assume it's similar for Python.

Kevin Chen
  • 186
  • 4
2

Python probably suffers from lack of cpu cache. I'm not sure how you can measure that easily though

John La Rooy
  • 12,005
  • 9
  • 48
  • 77