-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
The worst case sample time is also O(n) (or O(1) with a large constant factor, if you prefer to think about it that way), achieved when the list of levels starts with a lot of zeros:
julia> using DynamicSampling, Chairmarks
julia> ds = DynamicSampler()
DynamicSampler(Tuple{Int64, Float64}[])
julia> push!(ds, 1, 1.0)
DynamicSampler([(1, 1.0)])
julia> @b ds rand
8.429 ns
julia> for i in 2:1000
push!(ds, i, 2.0^i)
end
julia> @b ds rand
16.424 ns
julia> for i in 2:1000
delete!(ds, i)
end
julia> @b ds rand
1.292 μs (1 allocs: 48 bytes)It's possible that this could be fixed by performing a partial sort while traversing the list during sampling, though maybe there's another way with less sampling overhead.
Metadata
Metadata
Assignees
Labels
No labels