diff --git a/src/BaseBenchmarks.jl b/src/BaseBenchmarks.jl index 87031aa..b0cdbb9 100644 --- a/src/BaseBenchmarks.jl +++ b/src/BaseBenchmarks.jl @@ -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...) diff --git a/src/persistent/PersistentBenchmarks.jl b/src/persistent/PersistentBenchmarks.jl new file mode 100644 index 0000000..c0025e9 --- /dev/null +++ b/src/persistent/PersistentBenchmarks.jl @@ -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 \ No newline at end of file