In [1]:
versioninfo()
Julia Version 0.6.1
Commit 0d7248e2ff* (2017-10-24 22:15 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i3-3240 CPU @ 3.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, ivybridge)
In [2]:
run(`python --version`)
Python 3.6.0 :: Anaconda 4.3.0 (64-bit)
In [3]:
nprocs()
Out[3]:
1
In [4]:
tic()
run(`python ./Python/lorenz.py`)
toc()
elapsed time: 0.834317399 seconds
Out[4]:
0.834317399
In [5]:
tic()
run(`julia ./julia/lorenz.jl`)
a = toq()
Out[5]:
0.340066639
In [6]:
tic()
run(`python ./Python/lorenz.numba.py`)
toc()
elapsed time: 0.838595068 seconds
Out[6]:
0.838595068
In [7]:
tic()
run(`python ./Python/lorenz.swig.py`)
toc()
elapsed time: 0.265932662 seconds
Out[7]:
0.265932662
In [8]:
function lorenz()
    dt = 0.01
    n  = 200000

    a = 10.
    b = 28.
    c = 8/3

    x = zeros(n)
    y = zeros(n)
    z = zeros(n)

    x[1] = 0
    y[1] = 1.
    z[1] = 1.05

    for i = 1:n-1
        x[i+1] = x[i] + dt * (- a    * x[i] + a * y[i])
        y[i+1] = y[i] + dt * (- x[i] * z[i] + b * x[i] - y[i])
        z[i+1] = z[i] + dt * ( x[i]  * y[i] - c * z[i] )
    end
    return x,y,z
end
gx,gy,gz = lorenz()
Out[8]:
([0.0, 0.1, 0.189, 0.270808, 0.348532, 0.424755, 0.501673, 0.581205, 0.665079, 0.754902  …  0.148903, 0.0770094, 0.0142008, -0.0410513, -0.0900992, -0.134137, -0.174219, -0.211276, -0.246131, -0.279516], [1.0, 0.99, 1.00708, 1.04805, 1.11076, 1.19394, 1.29699, 1.41994, 1.56331, 1.72809  …  -0.570029, -0.551077, -0.53832, -0.53153, -0.530479, -0.534958, -0.544785, -0.559823, -0.579982, -0.605222], [1.05, 1.022, 0.995737, 0.971087, 0.94803, 0.92662, 0.906982, 0.889302, 0.87384, 0.860935  …  19.1004, 18.5902, 18.0941, 17.6115, 17.1421, 16.6854, 16.2412, 15.8091, 15.3887, 14.9797])
In [9]:
tic()
gx,gy,gz = lorenz()
toc()
elapsed time: 0.005617327 seconds
In [10]:
using PyCall
unshift!(PyVector(pyimport("sys")["path"]), "")
@pyimport _SwigMod as SwigMod
In [11]:
tic()
dt = 0.01
n  = 200000

a = 10.
b = 28.
c = 8/3

x = zeros(n)
y = zeros(n)
z = zeros(n)

x[1] = 0
y[1] = 1.
z[1] = 1.05

SwigMod.Swig_Lorenz(x, y, z, a, b, c, dt, n)
toc()
elapsed time: 0.508667328 seconds
Out[11]:
0.508667328
In [12]:
tic()
dt = 0.01
n  = 200000

a = 10.
b = 28.
c = 8/3

x = zeros(n)
y = zeros(n)
z = zeros(n)

x[1] = 0
y[1] = 1.
z[1] = 1.05

SwigMod.Swig_Lorenz(x, y, z, a, b, c, dt, n)
toc()
elapsed time: 0.005418702 seconds
Out[12]:
0.005418702