OrderedCollections.jl icon indicating copy to clipboard operation
OrderedCollections.jl copied to clipboard

Benchmarking the performance of dictionaries

Open eulerkochy opened this issue 5 years ago • 4 comments

Benchmarking code for the dictionaries is not present at the moment. I'll be happy to write a benchmark for the dictionaries. A sign of approval/necessity is all that I am waiting for !

eulerkochy avatar Feb 20 '20 20:02 eulerkochy

Yes, that would be great.

The current code for benchmarking in DataStructures.jl is nice a setup using PkgBenchmarks.jl https://github.com/JuliaCollections/DataStructures.jl/tree/master/benchmark

oxinabox avatar Feb 20 '20 20:02 oxinabox

Please do, or I will... for the OrderedDict and variants, OrderedRobinDict, LittleDict (that is ordered and fastest, but only for small dicts) etc.

PallHaraldsson avatar Oct 17 '20 00:10 PallHaraldsson

@PallHaraldsson I'd written a benchmark suite for AbstractDict types here. It can be extended to benchmark OrderedDicts as well. Please feel free to make a PR. I'm pretty loaded with coursework at this moment, but if it's urgent, cc me on the PR, I'll review it. 😄

eulerkochy avatar Oct 18 '20 04:10 eulerkochy

Hi @eulerkochy, I ran your code, thanks! I'm not sure which operation is most important, maybe pop! or find-failure:

find-failure OrderedRobinDict{Int64,Int64}() 10^4 elem Int64 minimum time TrialEstimate(40.000 ns) find-failure base-Dict{Int64,Int64}() 10^4 elem Int64 minimum time TrialEstimate(59.000 ns) find-failure SwissDict() 10^4 elem Int64 minimum time TrialEstimate(40.000 ns)

It's good to know OrderedRobinDict isn't slower (for this) than Base. Would you recommend that or something else, e.g. your new OrderedGeneralDict, I just discovered (as not merged), to replace Dict in Base? I thought one of the objection to change to ordered by default would be some new unordered might be even faster, and your SwissDict, should be the go to option to look into?

julia> filter_result(results, "pop!", "Dict")
pop! SwissDict{Float64,Float64}() 10^4 elem Float64 memory 0.0 kB
pop! SwissDict{Float64,Float64}() 10^4 elem Float64 minimum time TrialEstimate(47.000 ns)
pop! OrderedRobinDict{Float64,Float64}() 10^4 elem Float64 memory 0.0 kB
pop! OrderedRobinDict{Float64,Float64}() 10^4 elem Float64 minimum time TrialEstimate(90.000 ns)
pop! OrderedRobinDict() 10^4 elem Int64 memory 0.0 kB
pop! OrderedRobinDict() 10^4 elem Int64 minimum time TrialEstimate(96.000 ns)
pop! SwissDict() 10^4 elem Float64 memory 0.0 kB
pop! SwissDict() 10^4 elem Float64 minimum time TrialEstimate(62.000 ns)
pop! OrderedRobinDict() 10^4 elem Float64 memory 0.0 kB
pop! OrderedRobinDict() 10^4 elem Float64 minimum time TrialEstimate(87.000 ns)
pop! base-Dict() 10^4 elem Float64 memory 0.0 kB
pop! base-Dict() 10^4 elem Float64 minimum time TrialEstimate(43.000 ns)
pop! base-Dict() 10^4 elem Int64 memory 0.0 kB
pop! base-Dict() 10^4 elem Int64 minimum time TrialEstimate(41.000 ns)
pop! SwissDict{Int64,Int64}() 10^4 elem Int64 memory 0.0 kB
pop! SwissDict{Int64,Int64}() 10^4 elem Int64 minimum time TrialEstimate(53.000 ns)
pop! OrderedRobinDict{Int64,Int64}() 10^4 elem Int64 memory 0.0 kB
pop! OrderedRobinDict{Int64,Int64}() 10^4 elem Int64 minimum time TrialEstimate(121.000 ns)
pop! base-Dict{Int64,Int64}() 10^4 elem Int64 memory 0.0 kB
pop! base-Dict{Int64,Int64}() 10^4 elem Int64 minimum time TrialEstimate(51.000 ns)
pop! SwissDict() 10^4 elem Int64 memory 0.0 kB
pop! SwissDict() 10^4 elem Int64 minimum time TrialEstimate(52.000 ns)
pop! base-Dict{Float64,Float64}() 10^4 elem Float64 memory 0.0 kB
pop! base-Dict{Float64,Float64}() 10^4 elem Float64 minimum time TrialEstimate(44.000 ns)

PallHaraldsson avatar Oct 18 '20 17:10 PallHaraldsson