Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 0.6 Approach
- using BenchmarkTools
- using NullableArrays
- n = 10_000_000
- x = rand(n)
- y = NullableArray{Float64}(n)
- for i in 1:n
- if !iseven(i)
- y[i] = x[i]
- end
- end
- sum(x)
- sum(y)
- @benchmark sum($x)
- @benchmark sum($y)
- # 0.7 Approach
- using BenchmarkTools
- n = 10_000_000
- x = rand(n)
- y = [ifelse(iseven(i), missing, x[i]) for i in 1:n]
- sum(x)
- sum(y)
- @benchmark sum($x)
- @benchmark sum($y)
Add Comment
Please, Sign In to add comment