Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/BaseBenchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const MODULES = Dict("array" => :ArrayBenchmarks,
"frontend" => :FrontendBenchmarks,
)
@static VERSION ≥ v"1.8-DEV" && push!(MODULES, "inference" => :InferenceBenchmarks)
if VERSION >= v"1.11-DEV"
push!(MODULES, "persistent" => :PersistentBenchmarks)
end

load!(id::AbstractString; kwargs...) = load!(SUITE, id; kwargs...)

Expand Down
40 changes: 40 additions & 0 deletions src/persistent/PersistentBenchmarks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module CollectionBenchmarks

using BenchmarkTools
using Random
using StableRNGs

import Base: PersistentDict, ImmutableDict

using BenchmarkTools
using Random
using StableRNGs

const SUITE = BenchmarkGroup()

const RNG = StableRNG(1)

function create(::Type{Dict}, values::Vector{Pair{K,V}}) where {Dict, K, V}
dict = Dict{K,V}()
for p in values
dict = Dict(dict, p)
end
dict
end

mutable struct Key{T}
k::T
end

g = addgroup!(SUITE, "initialization", ["Associative", "persistent"])

for N in (256, 512, 1024, 2048)
ints = [i=>i for i in 1:N]
mints = [Key(i)=>i for i in 1:N]
g["ImmutableDict", "Int=>Int", N] = @benchmarkable create(ImmutableDict, $ints)
g["PersistentDict", "Int=>Int", N] = @benchmarkable create(PersistentDict, $ints)
g["ImmutableDict", "Key{Int}=>Int", N] = @benchmarkable create(ImmutableDict, $mints)
g["PersistentDict", "Key{Int}=>Int", N] = @benchmarkable create(PersistentDict, $mints)
end

end