In [1]:
from heat_diffusion_experiment import python_version, cython_version, cython_parallel_version
import matplotlib.pyplot as plt
import matplotlib
import numpy as np
%matplotlib inline

Run until t = 500s


In [3]:
n = 200

In [4]:
A = cython_version(n)
plt.pcolormesh(np.linspace(0, 1, n) , np.linspace(0, 1, n) , A)


Out[4]:
<matplotlib.collections.QuadMesh at 0x5d57f884a8>

Pure Python version


In [5]:
%%timeit
python_version(n)


1 loop, best of 3: 16min 9s per loop

Cython


In [6]:
%%timeit
cython_version(n)


1 loop, best of 3: 2.36 s per loop

Numpy vectorized version


In [ ]:
# TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO

Cython with Open MP


In [7]:
%%timeit
cython_parallel_version(n)


1 loop, best of 3: 1.5 s per loop

Fixed number of timesteps


In [8]:
num_timesteps=100

100x100 cells


In [9]:
%%timeit
cython_version(100,num_timesteps)


100 loops, best of 3: 4.92 ms per loop

In [10]:
%%timeit
cython_parallel_version(100,num_timesteps)


100 loops, best of 3: 3.3 ms per loop

200x200 cells


In [11]:
%%timeit
cython_version(200,num_timesteps)


100 loops, best of 3: 16.2 ms per loop

In [12]:
%%timeit
cython_parallel_version(200,num_timesteps)


100 loops, best of 3: 12.1 ms per loop

500x500 cells


In [13]:
%%timeit
cython_version(500,num_timesteps)


10 loops, best of 3: 166 ms per loop

In [14]:
%%timeit
cython_parallel_version(500,num_timesteps)


10 loops, best of 3: 78.3 ms per loop

1000x1000 cells


In [15]:
%%timeit
cython_version(1000,num_timesteps)


1 loop, best of 3: 666 ms per loop

In [16]:
%%timeit
cython_parallel_version(1000,num_timesteps)


1 loop, best of 3: 331 ms per loop

5000x5000 cells


In [17]:
%%timeit
cython_version(5000,num_timesteps)


1 loop, best of 3: 16.7 s per loop

In [18]:
%%timeit
cython_parallel_version(5000,num_timesteps)


1 loop, best of 3: 8.7 s per loop

10000x10000 cells


In [19]:
%%timeit
cython_version(10000,num_timesteps)


1 loop, best of 3: 1min 6s per loop

In [20]:
%%timeit
cython_parallel_version(10000,num_timesteps)


1 loop, best of 3: 28.2 s per loop

20000x20000 cells


In [6]:
%%timeit
cython_version(20000,num_timesteps)


1 loop, best of 3: 4min 25s per loop

In [5]:
%%timeit
cython_parallel_version(20000,num_timesteps)


1 loop, best of 3: 1min 58s per loop