Skip to content

Commit 18e1dd5

Browse files
committed
adjust base case size, add a few benchmarks to README
1 parent 8ebc90e commit 18e1dd5

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,25 @@ searchsortedfirstcorrelated(v::AbstractVector, x, guess)
4646

4747
An accelerated `findfirst` on sorted vectors using a bracketed search. Requires a `guess`
4848
to start the search from.
49+
50+
51+
Some benchmarks:
52+
```julia
53+
julia> x = rand(Int, 2048); s = sort(x);
54+
55+
julia> @btime findfirst(==($x[1011]), $x)
56+
266.427 ns (0 allocations: 0 bytes)
57+
1011
58+
59+
julia> @btime FindFirstFunctions.findfirstequal($x[1011], $x)
60+
67.502 ns (0 allocations: 0 bytes)
61+
1011
62+
63+
julia> @btime searchsortedfirst($s, $s[1011])
64+
8.897 ns (0 allocations: 0 bytes)
65+
1011
66+
67+
julia> @btime FindFirstFunctions.findfirstsortedequal($s[1011], $s)
68+
10.896 ns (0 allocations: 0 bytes)
69+
1011
70+
```

src/FindFirstFunctions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ end
7979
Note that this differs from `searchsortedfirst` by returning `nothing` when absent.
8080
"""
8181
function findfirstsortedequal(var::Int64, vars::DenseVector{Int64},
82-
::Val{basecase}=Val(64)) where {basecase}
82+
::Val{basecase}=Val(16)) where {basecase}
8383
len = length(vars)
8484
offset = 0
8585
@inbounds while len > basecase

0 commit comments

Comments
 (0)