Skip to content

Instantly share code, notes, and snippets.

@samuelcolvin
Created July 3, 2014 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuelcolvin/9afa1f431b06224ce823 to your computer and use it in GitHub Desktop.
Save samuelcolvin/9afa1f431b06224ce823 to your computer and use it in GitHub Desktop.
rand, cumprod Julia vs. Python
x = rand(1000,100)
repeats = 1000
f1 = () -> cumprod(x,1)
print(" f1: ")
@time [f1() for i in 1:repeats]
f2() = cumprod(x, 1)
print(" f2: ")
@time [f2() for i in 1:repeats]
f3(x) = cumprod(x, 1)
print(" f3: ")
@time [f3(x) for i in 1:repeats]
# for reference here's the julia version
versioninfo()
import numpy as np
from time import time
x = np.random.rand(1000,100)
start = time()
for i in range(1000):
np.cumprod(x,0)
finish = time()
print 'time taken %0.3f' % (finish - start)
samuel:Desktop || python py_vs_jl.py
time taken 0.437
samuel:Desktop || julia py_vs_jl.jl
f1: elapsed time: 0.50526759 seconds (801644424 bytes allocated, 4.22% gc time)
f2: elapsed time: 0.376359017 seconds (800111592 bytes allocated, 7.38% gc time)
f3: elapsed time: 0.370701405 seconds (800111592 bytes allocated, 3.87% gc time)
Julia Version 0.3.0-prerelease+4017
Commit 56da98a* (2014-07-02 12:18 UTC)
Platform Info:
System: Linux (x86_64-linux-gnu)
CPU: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY)
LAPACK: libopenblas
LIBM: libopenlibm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment