{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/19170","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/19170/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/19170/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/19170/events","html_url":"https://github.com/JuliaLang/julia/issues/19170","id":186402824,"number":19170,"title":"Performance regression using type assertion","user":{"login":"jw3126","id":7261506,"avatar_url":"https://avatars.githubusercontent.com/u/7261506?v=3","gravatar_id":"","url":"https://api.github.com/users/jw3126","html_url":"https://github.com/jw3126","followers_url":"https://api.github.com/users/jw3126/followers","following_url":"https://api.github.com/users/jw3126/following{/other_user}","gists_url":"https://api.github.com/users/jw3126/gists{/gist_id}","starred_url":"https://api.github.com/users/jw3126/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jw3126/subscriptions","organizations_url":"https://api.github.com/users/jw3126/orgs","repos_url":"https://api.github.com/users/jw3126/repos","events_url":"https://api.github.com/users/jw3126/events{/privacy}","received_events_url":"https://api.github.com/users/jw3126/received_events","type":"User","site_admin":false},"labels":[{"id":115858,"url":"https://api.github.com/repos/JuliaLang/julia/labels/performance","name":"performance","color":"d7e102","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-10-31T21:30:42Z","updated_at":"2016-10-31T21:53:59Z","closed_at":null,"body":"I have two functions that are the same except one uses the local keyword:\r\n```jl\r\nfunction doit{T}(arr::Vector{T})\r\n    local x::T\r\n    x = arr[1]\r\n    @inbounds for i in 1:length(arr)\r\n        x += arr[i]\r\n    end\r\n    x\r\nend\r\n\r\nfunction doit2{T}(arr::Vector{T})\r\n    x = arr[1]\r\n    @inbounds for i in 1:length(arr)\r\n        x += arr[i]\r\n    end\r\n    x\r\nend\r\n\r\narr = randn(10^5)\r\n```\r\nNow look at their performance:\r\n\r\n```\r\n@benchmark doit(arr)\r\nBenchmarkTools.Trial: \r\n  samples:          10000\r\n  evals/sample:     1\r\n  time tolerance:   5.00%\r\n  memory tolerance: 1.00%\r\n  memory estimate:  16.00 bytes\r\n  allocs estimate:  1\r\n  minimum time:     147.46 μs (0.00% GC)\r\n  median time:      151.95 μs (0.00% GC)\r\n  mean time:        155.10 μs (0.00% GC)\r\n  maximum time:     290.57 μs (0.00% GC)\r\n```\r\n\r\n```\r\n@benchmark doit2(arr)`\r\nBenchmarkTools.Trial: \r\n  samples:          10000\r\n  evals/sample:     1\r\n  time tolerance:   5.00%\r\n  memory tolerance: 1.00%\r\n  memory estimate:  16.00 bytes\r\n  allocs estimate:  1\r\n  minimum time:     88.50 μs (0.00% GC)\r\n  median time:      88.52 μs (0.00% GC)\r\n  mean time:        89.07 μs (0.00% GC)\r\n  maximum time:     144.94 μs (0.00% GC)\r\n```"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/257432235","html_url":"https://github.com/JuliaLang/julia/issues/19170#issuecomment-257432235","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/19170","id":257432235,"user":{"login":"yuyichao","id":712232,"avatar_url":"https://avatars.githubusercontent.com/u/712232?v=3","gravatar_id":"","url":"https://api.github.com/users/yuyichao","html_url":"https://github.com/yuyichao","followers_url":"https://api.github.com/users/yuyichao/followers","following_url":"https://api.github.com/users/yuyichao/following{/other_user}","gists_url":"https://api.github.com/users/yuyichao/gists{/gist_id}","starred_url":"https://api.github.com/users/yuyichao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuyichao/subscriptions","organizations_url":"https://api.github.com/users/yuyichao/orgs","repos_url":"https://api.github.com/users/yuyichao/repos","events_url":"https://api.github.com/users/yuyichao/events{/privacy}","received_events_url":"https://api.github.com/users/yuyichao/received_events","type":"User","site_admin":false},"created_at":"2016-10-31T21:53:59Z","updated_at":"2016-10-31T21:53:59Z","body":"Note that it isn't really an assertion."}}
{"actor":{"display_login":"yuyichao"}}