-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
collectionsData structures holding multiple items, e.g. setsData structures holding multiple items, e.g. setsperformanceMust go fasterMust go fasterpotential benchmarkCould make a good benchmark in BaseBenchmarksCould make a good benchmark in BaseBenchmarksrandomnessRandom number generation and the Random stdlibRandom number generation and the Random stdlib
Description
It is three times slower than this alternative implementation
julia> myrand(v) = (i = ceil(Int,rand()*length(v)); v[i])
julia> @benchmark rand(1:100)
BenchmarkTools.Trial:
memory estimate: 0 bytes
allocs estimate: 0
--------------
minimum time: 36.048 ns (0.00% GC)
median time: 36.996 ns (0.00% GC)
mean time: 37.104 ns (0.00% GC)
maximum time: 66.210 ns (0.00% GC)
--------------
samples: 10000
evals/sample: 993
time tolerance: 5.00%
memory tolerance: 1.00%
julia> @benchmark myrand(1:100)
BenchmarkTools.Trial:
memory estimate: 0 bytes
allocs estimate: 0
--------------
minimum time: 11.824 ns (0.00% GC)
median time: 12.332 ns (0.00% GC)
mean time: 12.286 ns (0.00% GC)
maximum time: 35.627 ns (0.00% GC)
--------------
samples: 10000
evals/sample: 999
time tolerance: 5.00%
memory tolerance: 1.00%Metadata
Metadata
Assignees
Labels
collectionsData structures holding multiple items, e.g. setsData structures holding multiple items, e.g. setsperformanceMust go fasterMust go fasterpotential benchmarkCould make a good benchmark in BaseBenchmarksCould make a good benchmark in BaseBenchmarksrandomnessRandom number generation and the Random stdlibRandom number generation and the Random stdlib