Last active
August 29, 2015 14:20
-
-
Save carlobaldassi/682827226945a3ff5005 to your computer and use it in GitHub Desktop.
abstractsmart benchmarking
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
abstractvector getindex A[I] | |
--------------------- | |
A::BitArray I::Vector{Int} | |
elapsed time: 0.271078954 seconds (4 MB allocated) | |
A::Array{Bool} I::Vector{Int} | |
elapsed time: 0.096585028 seconds (35 MB allocated) | |
A::Array{Float64} I::Vector{Int} | |
elapsed time: 0.267021423 seconds (286 MB allocated) | |
abstractvector setindex! A[I]=X | |
------------------------ | |
A::BitArray I::Vector{Int} X::Bool | |
elapsed time: 0.138103935 seconds (32 bytes allocated) | |
A::Array{Bool} I::Vector{Int} X::Bool | |
elapsed time: 0.054845261 seconds (0 bytes allocated) | |
A::Array{Float64} I::Vector{Int} X::Bool | |
elapsed time: 0.081660954 seconds (0 bytes allocated) | |
A::BitArray I::Vector{Int} X::BitArray | |
elapsed time: 0.295849364 seconds (16 bytes allocated) | |
A::Vector{Bool} I::Vector{Int} X::BitArray | |
elapsed time: 0.085831136 seconds (0 bytes allocated) | |
A::Vector{Float64} I::Vector{Int} X::BitArray | |
elapsed time: 0.108971498 seconds (0 bytes allocated) | |
A::BitArray I::Vector{Int} X::Vector{Bool} | |
elapsed time: 0.274603976 seconds (16 bytes allocated) | |
A::Vector{Bool} I::Vector{Int} X::Vector{Bool} | |
elapsed time: 0.074821979 seconds (0 bytes allocated) | |
A::Vector{Float64} I::Vector{Int} X::Vector{Bool} | |
elapsed time: 0.089522974 seconds (0 bytes allocated) | |
A::BitArray I::Vector{Int} X::Vector{Float64} | |
elapsed time: 0.374606447 seconds (16 bytes allocated) | |
A::Vector{Bool} I::Vector{Int} X::Vector{Float64} | |
elapsed time: 0.325665311 seconds (0 bytes allocated) | |
A::Vector{Float64} I::Vector{Int} X::Vector{Float64} | |
elapsed time: 0.099550323 seconds (0 bytes allocated) |
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
function bench() | |
b = bitrand(500 * 500 * 300) | |
i = find(bitrand(500 * 500 * 300)) | |
t = vec(bitrand(length(i))) | |
c = bitunpack(b) | |
y = bitunpack(t) | |
d = map(Float64, c) | |
w = map(Float64, y) | |
println("abstractvector getindex A[I]") | |
println("---------------------") | |
println("A::BitArray I::Vector{Int}") | |
@time b[i] | |
println("A::Array{Bool} I::Vector{Int}") | |
@time c[i] | |
println("A::Array{Float64} I::Vector{Int}") | |
@time d[i] | |
println() | |
println("abstractvector setindex! A[I]=X") | |
println("------------------------") | |
println("A::BitArray I::Vector{Int} X::Bool") | |
@time b[i] = true | |
println("A::Array{Bool} I::Vector{Int} X::Bool") | |
@time c[i] = true | |
println("A::Array{Float64} I::Vector{Int} X::Bool") | |
@time d[i] = true | |
println() | |
println("A::BitArray I::Vector{Int} X::BitArray") | |
@time b[i] = t | |
println("A::Vector{Bool} I::Vector{Int} X::BitArray") | |
@time c[i] = t | |
println("A::Vector{Float64} I::Vector{Int} X::BitArray") | |
@time d[i] = t | |
println() | |
println("A::BitArray I::Vector{Int} X::Vector{Bool}") | |
@time b[i] = y | |
println("A::Vector{Bool} I::Vector{Int} X::Vector{Bool}") | |
@time c[i] = y | |
println("A::Vector{Float64} I::Vector{Int} X::Vector{Bool}") | |
@time d[i] = y | |
println() | |
println("A::BitArray I::Vector{Int} X::Vector{Float64}") | |
@time b[i] = w | |
println("A::Vector{Bool} I::Vector{Int} X::Vector{Float64}") | |
@time c[i] = w | |
println("A::Vector{Float64} I::Vector{Int} X::Vector{Float64}") | |
@time d[i] = w | |
nothing | |
end | |
bench() |
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
abstractvector getindex A[I] | |
--------------------- | |
A::BitArray I::Vector{Int} | |
elapsed time: 0.261341763 seconds (4 MB allocated) | |
A::Array{Bool} I::Vector{Int} | |
elapsed time: 0.077055085 seconds (35 MB allocated) | |
A::Array{Float64} I::Vector{Int} | |
elapsed time: 0.235785942 seconds (286 MB allocated) | |
abstractvector setindex! A[I]=X | |
------------------------ | |
A::BitArray I::Vector{Int} X::Bool | |
elapsed time: 0.161912213 seconds (0 bytes allocated) | |
A::Array{Bool} I::Vector{Int} X::Bool | |
elapsed time: 0.047390598 seconds (0 bytes allocated) | |
A::Array{Float64} I::Vector{Int} X::Bool | |
elapsed time: 0.083900891 seconds (0 bytes allocated) | |
A::BitArray I::Vector{Int} X::BitArray | |
elapsed time: 0.340454919 seconds (0 bytes allocated) | |
A::Vector{Bool} I::Vector{Int} X::BitArray | |
elapsed time: 3.431763512 seconds (4005 MB allocated, 6.27% gc time in 183 pauses with 1 full sweep) | |
A::Vector{Float64} I::Vector{Int} X::BitArray | |
elapsed time: 3.433284389 seconds (4005 MB allocated, 5.74% gc time in 183 pauses with 0 full sweep) | |
A::BitArray I::Vector{Int} X::Vector{Bool} | |
elapsed time: 0.300707838 seconds (0 bytes allocated) | |
A::Vector{Bool} I::Vector{Int} X::Vector{Bool} | |
elapsed time: 3.373181104 seconds (4005 MB allocated, 5.81% gc time in 183 pauses with 0 full sweep) | |
A::Vector{Float64} I::Vector{Int} X::Vector{Bool} | |
elapsed time: 3.431137863 seconds (4005 MB allocated, 5.73% gc time in 183 pauses with 0 full sweep) | |
A::BitArray I::Vector{Int} X::Vector{Float64} | |
elapsed time: 0.408039837 seconds (0 bytes allocated) | |
A::Vector{Bool} I::Vector{Int} X::Vector{Float64} | |
elapsed time: 3.664624911 seconds (4005 MB allocated, 5.36% gc time in 183 pauses with 0 full sweep) | |
A::Vector{Float64} I::Vector{Int} X::Vector{Float64} | |
elapsed time: 3.413541873 seconds (4005 MB allocated, 5.84% gc time in 183 pauses with 0 full sweep) |
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
logical getindex A[I] | |
--------------------- | |
A::BitArray I::BitArray | |
elapsed time: 0.666670208 seconds (4 MB allocated) | |
A::BitArray I::Array | |
elapsed time: 0.858525449 seconds (4 MB allocated, 2.84% gc time in 1 pauses with 0 full sweep) | |
A::Array I::BitArray | |
elapsed time: 0.437898449 seconds (35 MB allocated) | |
A::Array I::Array | |
elapsed time: 0.657147082 seconds (35 MB allocated) | |
logical setindex! A[I]=X | |
------------------------ | |
A::BitArray I::BitArray X::Bool | |
elapsed time: 0.00152788 seconds (0 bytes allocated) | |
A::BitArray I::Array X::Bool | |
elapsed time: 0.523627324 seconds (0 bytes allocated) | |
A::Array I::BitArray X::Bool | |
elapsed time: 0.426918878 seconds (0 bytes allocated) | |
A::Array I::Array X::Bool | |
elapsed time: 0.636965195 seconds (0 bytes allocated) | |
A::BitArray I::BitArray X::BitArray | |
elapsed time: 0.464906295 seconds (0 bytes allocated) | |
A::BitArray I::BitArray X::Array | |
elapsed time: 0.408413017 seconds (0 bytes allocated) | |
A::BitArray I::Array X::BitArray | |
elapsed time: 0.524728359 seconds (0 bytes allocated) | |
A::BitArray I::Array X::Array | |
elapsed time: 0.505638713 seconds (0 bytes allocated) | |
A::Array I::BitArray X::BitArray | |
elapsed time: 0.428551069 seconds (0 bytes allocated) | |
A::Array I::BitArray X::Array | |
elapsed time: 0.410027661 seconds (0 bytes allocated) | |
A::Array I::Array X::BitArray | |
elapsed time: 0.634777484 seconds (0 bytes allocated) | |
A::Array I::Array X::Array | |
elapsed time: 0.626040639 seconds (0 bytes allocated) |
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
function bench() | |
b = bitrand(500, 500, 300) | |
i = bitrand(500, 500, 300) | |
t = vec(bitrand(sum(i))) | |
c = bitunpack(b) | |
j = bitunpack(i) | |
y = bitunpack(t) | |
println("logical getindex A[I]") | |
println("---------------------") | |
println("A::BitArray I::BitArray") | |
@time b[i] | |
println("A::BitArray I::Array") | |
@time b[j] | |
println("A::Array I::BitArray") | |
@time c[i] | |
println("A::Array I::Array") | |
@time c[j] | |
println() | |
println("logical setindex! A[I]=X") | |
println("------------------------") | |
println("A::BitArray I::BitArray X::Bool") | |
@time b[i] = true | |
println("A::BitArray I::Array X::Bool") | |
@time b[j] = true | |
println("A::Array I::BitArray X::Bool") | |
@time c[i] = true | |
println("A::Array I::Array X::Bool") | |
@time c[j] = true | |
println() | |
println("A::BitArray I::BitArray X::BitArray") | |
@time b[i] = t | |
println("A::BitArray I::BitArray X::Array") | |
@time b[i] = y | |
println("A::BitArray I::Array X::BitArray") | |
@time b[j] = t | |
println("A::BitArray I::Array X::Array") | |
@time b[j] = y | |
println("A::Array I::BitArray X::BitArray") | |
@time c[i] = t | |
println("A::Array I::BitArray X::Array") | |
@time c[i] = y | |
println("A::Array I::Array X::BitArray") | |
@time c[j] = t | |
println("A::Array I::Array X::Array") | |
@time c[j] = y | |
nothing | |
end | |
bench() |
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
logical getindex A[I] | |
--------------------- | |
A::BitArray I::BitArray | |
elapsed time: 0.60798166 seconds (4 MB allocated) | |
A::BitArray I::Array | |
elapsed time: 0.777329473 seconds (4 MB allocated) | |
A::Array I::BitArray | |
elapsed time: 0.432383244 seconds (35 MB allocated) | |
A::Array I::Array | |
elapsed time: 0.621484684 seconds (35 MB allocated) | |
logical setindex! A[I]=X | |
------------------------ | |
A::BitArray I::BitArray X::Bool | |
elapsed time: 0.001462389 seconds (0 bytes allocated) | |
A::BitArray I::Array X::Bool | |
elapsed time: 0.346264186 seconds (0 bytes allocated) | |
A::Array I::BitArray X::Bool | |
elapsed time: 0.402724992 seconds (0 bytes allocated) | |
A::Array I::Array X::Bool | |
elapsed time: 0.29331004 seconds (0 bytes allocated) | |
A::BitArray I::BitArray X::BitArray | |
elapsed time: 0.463646412 seconds (0 bytes allocated) | |
A::BitArray I::BitArray X::Array | |
elapsed time: 0.403772082 seconds (0 bytes allocated) | |
A::BitArray I::Array X::BitArray | |
elapsed time: 0.517578264 seconds (0 bytes allocated) | |
A::BitArray I::Array X::Array | |
elapsed time: 0.503648876 seconds (0 bytes allocated) | |
A::Array I::BitArray X::BitArray | |
elapsed time: 0.438264625 seconds (0 bytes allocated) | |
A::Array I::BitArray X::Array | |
elapsed time: 0.414854685 seconds (0 bytes allocated) | |
A::Array I::Array X::BitArray | |
elapsed time: 0.330910095 seconds (0 bytes allocated) | |
A::Array I::Array X::Array | |
elapsed time: 0.310505032 seconds (0 bytes allocated) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment