Skip to content

Instantly share code, notes, and snippets.

@multidis
Created February 8, 2017 21:16
Show Gist options
  • Save multidis/ca16bed5fcdd29f88ca1e07973c9cd16 to your computer and use it in GitHub Desktop.
Save multidis/ca16bed5fcdd29f88ca1e07973c9cd16 to your computer and use it in GitHub Desktop.
Optim.jl timing, memory allocation issue https://github.com/JuliaOpt/Optim.jl/issues/292
using Optim
## try commenting out the log in this line, Optim src/problems/univariate.jl:
## p18(x) = x <= 3.0 ? (x-2.0)^2 : 2.0###*log(x-2.0)+1.0
function frunmap(nmap::Int64, nmat::Int64)
M = randn(nmat, nmat)
# closure to parallel-apply
function fmaploc(vi)
# not doing anything here
return 1.0
end
return pmap(fmaploc, collect(1:nmap))
end
Ntimes = 10
Nmatsize = 1_000
@time println(frunmap(Ntimes, Nmatsize))
@time frunmap(Ntimes, Nmatsize)
# repeat more times than CPU cores
@time frunmap(Ntimes, Nmatsize)
@time frunmap(Ntimes, Nmatsize)
@time frunmap(Ntimes, Nmatsize)
@time frunmap(Ntimes, Nmatsize)
@time frunmap(Ntimes, Nmatsize)
@time frunmap(Ntimes, Nmatsize)
@time frunmap(Ntimes, Nmatsize)
@time frunmap(Ntimes, Nmatsize)
@time frunmap(Ntimes, Nmatsize)
@time frunmap(Ntimes, Nmatsize)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment