Created
July 3, 2014 11:51
-
-
Save samuelcolvin/9afa1f431b06224ce823 to your computer and use it in GitHub Desktop.
rand, cumprod Julia vs. Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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