Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start adding benchmark for persistent datastructures #315

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
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

Check warning on line 22 in src/persistent/PersistentBenchmarks.jl

View check run for this annotation

Codecov / codecov/patch

src/persistent/PersistentBenchmarks.jl#L17-L22

Added lines #L17 - L22 were not covered by tests
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
Loading