Skip to content

Instantly share code, notes, and snippets.

@dionisos2
Last active August 3, 2019 17:11
Show Gist options
  • Save dionisos2/131571fa66d2df1e7783fe86920cddf8 to your computer and use it in GitHub Desktop.
Save dionisos2/131571fa66d2df1e7783fe86920cddf8 to your computer and use it in GitHub Desktop.
random poor benchmark
julia> using PyCall
julia> py"""
def pysum(lx, ly):
return sum(x*y for x in range(1,lx+1) for y in range(1,ly+1,3))
"""
julia> jlsum(lx, ly) = sum(x*y for x in 1:lx for y in 1:3:ly)
jlsum (generic function with 2 methods)
julia> function test()
println("python")
@time py"pysum(10000,10000)"
println("julia")
@time jlsum(10_000, 10_000)
end
test (generic function with 1 method)
julia> test()
python
1.909166 seconds (4 allocations: 64 bytes)
julia
0.014589 seconds (1 allocation: 32 bytes)
833666708335000
julia> jlsum(10000,10000) == py"pysum(10000,10000)"
true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment