{"action":"created","issue":{"url":"https://api.github.com/repos/sisl/PGFPlots.jl/issues/32","repository_url":"https://api.github.com/repos/sisl/PGFPlots.jl","labels_url":"https://api.github.com/repos/sisl/PGFPlots.jl/issues/32/labels{/name}","comments_url":"https://api.github.com/repos/sisl/PGFPlots.jl/issues/32/comments","events_url":"https://api.github.com/repos/sisl/PGFPlots.jl/issues/32/events","html_url":"https://github.com/sisl/PGFPlots.jl/pull/32","id":141819217,"number":32,"title":"Simplify 2D meshgrid.","user":{"login":"pkofod","id":8431156,"avatar_url":"https://avatars.githubusercontent.com/u/8431156?v=3","gravatar_id":"","url":"https://api.github.com/users/pkofod","html_url":"https://github.com/pkofod","followers_url":"https://api.github.com/users/pkofod/followers","following_url":"https://api.github.com/users/pkofod/following{/other_user}","gists_url":"https://api.github.com/users/pkofod/gists{/gist_id}","starred_url":"https://api.github.com/users/pkofod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pkofod/subscriptions","organizations_url":"https://api.github.com/users/pkofod/orgs","repos_url":"https://api.github.com/users/pkofod/repos","events_url":"https://api.github.com/users/pkofod/events{/privacy}","received_events_url":"https://api.github.com/users/pkofod/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-18T09:46:02Z","updated_at":"2016-03-18T16:25:58Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/sisl/PGFPlots.jl/pulls/32","html_url":"https://github.com/sisl/PGFPlots.jl/pull/32","diff_url":"https://github.com/sisl/PGFPlots.jl/pull/32.diff","patch_url":"https://github.com/sisl/PGFPlots.jl/pull/32.patch"},"body":""},"comment":{"url":"https://api.github.com/repos/sisl/PGFPlots.jl/issues/comments/198435865","html_url":"https://github.com/sisl/PGFPlots.jl/pull/32#issuecomment-198435865","issue_url":"https://api.github.com/repos/sisl/PGFPlots.jl/issues/32","id":198435865,"user":{"login":"pkofod","id":8431156,"avatar_url":"https://avatars.githubusercontent.com/u/8431156?v=3","gravatar_id":"","url":"https://api.github.com/users/pkofod","html_url":"https://github.com/pkofod","followers_url":"https://api.github.com/users/pkofod/followers","following_url":"https://api.github.com/users/pkofod/following{/other_user}","gists_url":"https://api.github.com/users/pkofod/gists{/gist_id}","starred_url":"https://api.github.com/users/pkofod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pkofod/subscriptions","organizations_url":"https://api.github.com/users/pkofod/orgs","repos_url":"https://api.github.com/users/pkofod/repos","events_url":"https://api.github.com/users/pkofod/events{/privacy}","received_events_url":"https://api.github.com/users/pkofod/received_events","type":"User","site_admin":false},"created_at":"2016-03-18T16:25:58Z","updated_at":"2016-03-18T16:25:58Z","body":"It seems there is\r\n\r\n```julia\r\nusing Benchmarks\r\n\r\nfunction meshgrid_old{T}(vx::AbstractVector{T}, vy::AbstractVector{T})\r\n    m, n = length(vy), length(vx)\r\n    vx = reshape(vx, 1, n)\r\n    vy = reshape(vy, m, 1)\r\n    (repmat(vx, m, 1), repmat(vy, 1, n))\r\nend\r\n\r\nfunction meshgrid{T}(vx::AbstractVector{T}, vy::AbstractVector{T})\r\n    (T[i for j in vy, i in vx], T[j for j in vy, i in vx])\r\nend\r\n\r\na = -10:10\r\nb = -10:10\r\n\r\n@benchmark meshgrid_old(a, b)\r\n================ Benchmark Results ========================\r\n     Time per evaluation: 6.75 μs [6.56 μs, 6.93 μs]\r\nProportion of time in GC: 0.00% [0.00%, 0.00%]\r\n        Memory allocated: 10.38 kb\r\n   Number of allocations: 95 allocations\r\n       Number of samples: 2401\r\n   Number of evaluations: 18901\r\n         R² of OLS model: 0.952\r\n Time spent benchmarking: 1.34 s\r\n\r\n\r\n@benchmark meshgrid(a, b)\r\n================ Benchmark Results ========================\r\n     Time per evaluation: 1.33 μs [1.31 μs, 1.35 μs]\r\nProportion of time in GC: 6.24% [5.22%, 7.26%]\r\n        Memory allocated: 7.09 kb\r\n   Number of allocations: 3 allocations\r\n       Number of samples: 8201\r\n   Number of evaluations: 4959001\r\n         R² of OLS model: 0.951\r\n Time spent benchmarking: 10.47 s\r\n\r\n\r\na = -100:100\r\nb = -100:100\r\n\r\n@benchmark meshgrid_old(a, b)\r\n================ Benchmark Results ========================\r\n     Time per evaluation: 161.37 μs [107.64 μs, 215.09 μs]\r\nProportion of time in GC: 1.31% [0.00%, 6.84%]\r\n        Memory allocated: 660.28 kb\r\n   Number of allocations: 817 allocations\r\n       Number of samples: 100\r\n   Number of evaluations: 100\r\n Time spent benchmarking: 0.12 s\r\n\r\n\r\n@benchmark meshgrid(a, b)\r\n================ Benchmark Results ========================\r\n     Time per evaluation: 81.50 μs [43.54 μs, 119.45 μs]\r\nProportion of time in GC: 1.48% [0.00%, 7.75%]\r\n        Memory allocated: 631.44 kb\r\n   Number of allocations: 5 allocations\r\n       Number of samples: 100\r\n   Number of evaluations: 100\r\n Time spent benchmarking: 0.11 s\r\n\r\n \r\n a = -1000:1000\r\n b = -1000:1000\r\n\r\n @benchmark meshgrid_old(a, b)\r\n ================ Benchmark Results ========================\r\n     Time per evaluation: 17.95 ms [2.65 ms, 33.24 ms]\r\nProportion of time in GC: 5.03% [4.47%, 5.58%]\r\n        Memory allocated: 61.37 mb\r\n   Number of allocations: 8023 allocations\r\n       Number of samples: 59\r\n   Number of evaluations: 59\r\n Time spent benchmarking: 1.25 s\r\n\r\n\r\n \r\n @benchmark meshgrid(a, b)\r\n ================ Benchmark Results ========================\r\n      Time per evaluation: 7.84 ms [7.59 ms, 8.09 ms]\r\n Proportion of time in GC: 9.13% [8.84%, 9.42%]\r\n         Memory allocated: 61.10 mb\r\n    Number of allocations: 5 allocations\r\n        Number of samples: 100\r\n    Number of evaluations: 100\r\n  Time spent benchmarking: 0.90 s\r\n\r\n\r\n```"}}