NullableArrays `map` perf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using NullableArrays | |
srand(1) | |
N = 5_000_000 | |
A = rand(N) | |
B = rand(Bool, N) | |
C = Array(Float64, N) | |
X = NullableArray(A) | |
Y = NullableArray(A, B) | |
Z = NullableArray(Float64, N) | |
f(x::Float64) = 5 * x | |
function profile_map() | |
println("Method: map!(f, dest, src) (0 missing entries, lift=true)") | |
print(" for Array{Float64}: ") | |
map!(f, C, A); | |
@time map!(f, C, A); | |
print(" for NullableArray{Float64}: ") | |
map!(f, Z, X; lift=true); | |
@time map!(f, Z, X; lift=true); | |
println() | |
println("Method: map!(f, dest, src) (~half missing entries, lift=true)") | |
print(" for NullableArray{Float64}: ") | |
map!(f, Z, Y; lift=true); | |
@time map!(f, Z, Y; lift=true); | |
println() | |
println("Method: map(f, src) (0 missing entries, lift=true)") | |
print(" for Array{Float64}: ") | |
map(f, A); | |
@time map(f, A); | |
print(" for NullableArray{Float64}: ") | |
map(f, X); | |
@time map(f, X); | |
println() | |
println("Method: map(f, src) (~half missing entries, lift=true)") | |
print(" for NullableArray{Float64}: ") | |
map(f, Y; lift=true); | |
@time map(f, Y; lift=true); | |
println() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment