Skip to content

Instantly share code, notes, and snippets.

@multidis
Created February 8, 2017 21:16
Show Gist options
  • Select an option

  • Save multidis/ca16bed5fcdd29f88ca1e07973c9cd16 to your computer and use it in GitHub Desktop.

Select an option

Save multidis/ca16bed5fcdd29f88ca1e07973c9cd16 to your computer and use it in GitHub Desktop.

Revisions

  1. multidis created this gist Feb 8, 2017.
    33 changes: 33 additions & 0 deletions optim_time_memalloc_issue.jl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    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)