Skip to content

Commit

Permalink
Using SkipLists for large windows
Browse files Browse the repository at this point in the history
  • Loading branch information
yha committed Jun 28, 2022
1 parent f39919e commit d944fb0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
6 changes: 4 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name = "RunningQuantiles"
uuid = "80c66bcf-cf80-4640-8128-20a4ffc975e3"
authors = ["yha <yharel@campus.technion.ac.il>"]
version = "0.1.0"
version = "0.1.1"

[deps]
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
SkipLists = "1bc1db3f-e088-4b4f-941a-131a3eb578db"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
OffsetArrays = "1.12"
julia = "1.7"
SkipLists = "1.1.1"
julia = "1.7"
9 changes: 5 additions & 4 deletions bench/benchmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ function make_v(p_nan = 0.1, n=10_000)
v
end

benches = Dict("FastRunningMedian" => (v,w) -> FastRunningMedian.running_median(v, w),
"RunningQuantiles" => (v,w) -> running_median(v, w),
"SortFilters" => (v,w) -> SortFilters.movsort(v, w, 0.5)
)
benches = OrderedDict(
"FastRunningMedian" => (v,w) -> FastRunningMedian.running_median(v, w),
"SortFilters" => (v,w) -> SortFilters.movsort(v, w, 0.5),
"RunningQuantiles" => (v,w) -> running_median(v, w),
)

function bench(f,k,n,w)
@info "Benchmarking $k, w=$w"
Expand Down
25 changes: 11 additions & 14 deletions src/RunningQuantiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ module RunningQuantiles

export running_quantile, running_median, SkipNaNs, PropagateNaNs, ErrOnNaN

# `SkipLists` will be used when a version including PR #21 is released
# using SkipLists
using SkipLists
using OffsetArrays
using Statistics

Expand Down Expand Up @@ -79,17 +78,15 @@ function _running_quantile(v, p, r::AbstractUnitRange, nan_mode; buffer)
result
end

#### To use when `SkipLists` support indexing (SkipLists PR #21)
# function default_buffer(v,p,w)
# # Heuristics derived from superficial benchmarking.
# # These can probably be improved.
# len = length(make_window(w))
# if len > 6000
# SkipList{eltype(v)}(; node_capacity = round(Int, len/10))
# else
# SortedVector{eltype(v)}()
# end
# end
default_buffer(v,p,w) = SortedVector{eltype(v)}()
function default_buffer(v,p,w)
# Heuristics derived from superficial benchmarking.
# These can probably be improved.
len = length(make_window(w))
if len > 6000
SkipList{eltype(v)}(; node_capacity = round(Int, len/10))
else
SortedVector{eltype(v)}()
end
end

end # module

2 comments on commit d944fb0

@yha
Copy link
Owner Author

@yha yha commented on d944fb0 Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/63289

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.1 -m "<description of version>" d944fb079d5ec24b75b0c03e93716a043a453197
git push origin v0.1.1

Please sign in to comment.