Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterating over UnitWeights is slow #600

Closed
matthieugomez opened this issue Sep 16, 2020 · 0 comments · Fixed by #602
Closed

Iterating over UnitWeights is slow #600

matthieugomez opened this issue Sep 16, 2020 · 0 comments · Fixed by #602

Comments

@matthieugomez
Copy link
Contributor

matthieugomez commented Sep 16, 2020

Iterating over UnitWeights is 30 times slower than iterating over a normal vector on my computer.

using StatsBase, BenchmarkTools
N = 1_000
y = ones(N)
w = UnitWeights{Float64}(N)
@btime sum(y[i] for i in 1:N)
#   36.911 μs (2490 allocations: 38.91 KiB)
@btime sum(w[i] for i in 1:N)
#   961.807 μs (9985 allocations: 234.22 KiB)
@matthieugomez matthieugomez changed the title Summing UnitWeights is slow Iterating over UnitWeights is slow Sep 16, 2020
nalimilan pushed a commit that referenced this issue Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant