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]:
run(`node --version`)
v8.9.4
In [4]:
nprocs()
Out[4]:
1
In [5]:
tic()
run(`julia ./julia/lorenz.200M.jl`)
toc()
elapsed time: 0.888894725 seconds
Out[5]:
0.888894725
In [6]:
tic()
run(`python ./Python/lorenz.swig.200M.py`)
toc()
elapsed time: 0.571528617 seconds
Out[6]:
0.571528617
In [7]:
tic()
run(`node ./JS/lorenz.20M.js`)
toc()
elapsed time: 0.46230484 seconds
Out[7]:
0.46230484
In [8]:
function lorenz()
    dt = 0.01
    n  = 20000000

    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  …  -8.50481, -8.26483, -8.02668, -7.79317, -7.56684, -7.34996, -7.14454, -6.95227, -6.77459, -6.61264], [1.0, 0.99, 1.00708, 1.04805, 1.11076, 1.19394, 1.29699, 1.41994, 1.56331, 1.72809  …  -6.10495, -5.88341, -5.69158, -5.52984, -5.39807, -5.29571, -5.22187, -5.17543, -5.15512, -5.1596], [1.05, 1.022, 0.995737, 0.971087, 0.94803, 0.92662, 0.906982, 0.889302, 0.87384, 0.860935  …  29.887, 29.6092, 29.3059, 28.9813, 28.6394, 28.2841, 27.9191, 27.5477, 27.1729, 26.7975])
In [9]:
tic()
gx,gy,gz = lorenz()
toc()
elapsed time: 0.400894595 seconds
Out[9]:
0.400894595
In [10]:
using PyCall
unshift!(PyVector(pyimport("sys")["path"]), "")
@pyimport _SwigMod as SwigMod
In [11]:
tic()
dt = 0.01
n  = 20000000

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.825153813 seconds
Out[11]:
0.825153813
In [12]:
tic()
dt = 0.01
n  = 20000000

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.508946548 seconds
Out[12]:
0.508946548