Created
June 27, 2018 12:28
-
-
Save johnmyleswhite/915a8f4834db23f29170e7f28b09eef6 to your computer and use it in GitHub Desktop.
Perf of Missing Values in Julia 0.7
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 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) |
library("microbenchmark")
n <- 10000000
x <- runif(n)
sum(x)
microbenchmark(sum(x))
> microbenchmark(sum(x))
Unit: milliseconds
expr min lq mean median uq max neval
sum(x) 9.147777 9.415088 9.938853 9.656602 10.27017 12.09193 100
It seems like comparing with R where there are NAs present would make sense, no?
Almost the same benchmarks appear in First-Class Statistical Missing Values Support in Julia 0.7 (do a page seach for "always allow"), but an R example with NAs is included. The result is the same as here: the R example without NAs is 2x slower than the Julia example. The R example with NAs is 2x again slower.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
julia> @benchmark sum($x)
BenchmarkTools.Trial:
memory estimate: 0 bytes
allocs estimate: 0
minimum time: 4.633 ms (0.00% GC)
median time: 5.285 ms (0.00% GC)
mean time: 5.444 ms (0.00% GC)
maximum time: 10.290 ms (0.00% GC)
samples: 916
evals/sample: 1
julia> @benchmark sum($y)
BenchmarkTools.Trial:
memory estimate: 0 bytes
allocs estimate: 0
minimum time: 10.661 ms (0.00% GC)
median time: 11.276 ms (0.00% GC)
mean time: 11.606 ms (0.00% GC)
maximum time: 22.728 ms (0.00% GC)
samples: 430
evals/sample: 1