Created
July 21, 2017 01:54
-
-
Save odow/600479bf4da04d81bb2f87875e63408b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
struct VarRef | |
x::UInt64 | |
end | |
function f(A, B) | |
s = 0 | |
for y in Y | |
s += X[y] | |
end | |
s | |
end | |
m = 100_000_000 | |
n = 100_000 | |
X = rand(Int, n); | |
Y = mod.(rand(Int, m), n) .+ 1; | |
Z = VarRef.(Y); | |
U = Dict{VarRef, Int}(); | |
for i in 1:length(X) | |
U[VarRef(i)] = X[i] | |
end | |
println("Array Access") | |
display(@benchmark f($X, $Y)) | |
println("\nDict Access") | |
display(@benchmark f($U, $Z)) |
This file contains hidden or 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
C:\Users\odow003\.julia\v0.6\CPLEX\src\MOI>D:/Julia/Julia-0.6/bin/Julia.exe benchmark.jl | |
Array Access | |
BenchmarkTools.Trial: | |
memory estimate: 8.93 GiB | |
allocs estimate: 499488209 | |
-------------- | |
minimum time: 14.547 s (2.61% GC) | |
median time: 14.547 s (2.61% GC) | |
mean time: 14.547 s (2.61% GC) | |
maximum time: 14.547 s (2.61% GC) | |
-------------- | |
samples: 1 | |
evals/sample: 1 | |
Dict Access | |
BenchmarkTools.Trial: | |
memory estimate: 8.93 GiB | |
allocs estimate: 499488209 | |
-------------- | |
minimum time: 14.247 s (2.78% GC) | |
median time: 14.247 s (2.78% GC) | |
mean time: 14.247 s (2.78% GC) | |
maximum time: 14.247 s (2.78% GC) | |
-------------- | |
samples: 1 | |
evals/sample: 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment