-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
047c1db
commit 84dbc5f
Showing
5 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
[deps] | ||
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" | ||
DispatchedTuples = "508c55e1-51b4-41fd-a5ca-7eb0327d070d" | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using DispatchedTuples | ||
using BenchmarkTools | ||
|
||
# (N, N_buf) are low for quick doc builds | ||
# (N, N_buf) = (5, 3) is reasonable | ||
N = 0 | ||
N_buf = 1 | ||
|
||
foo(i) = Symbol(:Foo, i) | ||
expr(i) = :(struct $(foo(i)) end) | ||
for i in 1:N+N_buf | ||
eval(expr(i)) | ||
end | ||
|
||
fooinst(i::Int) = eval(:($(foo(i))))() | ||
|
||
footup(n::Int) = ntuple(n) do i | ||
(fooinst(i), i) | ||
end | ||
|
||
function perf_dt(N, N_buf) | ||
println("********* DispatchedTuple") | ||
for n in N_buf:N+N_buf | ||
println("--- n = $n") | ||
tup = footup(n) | ||
@btime footup($n) | ||
|
||
dtup = DispatchedTuple(tup) | ||
@btime DispatchedTuple($tup) | ||
# @btime $dtup[Foo3()] # always results in 0.028 ns (0 allocations: 0 bytes) | ||
end | ||
end | ||
|
||
function perf_ds(N, N_buf) | ||
println("********* DispatchedSet") | ||
for n in N_buf:N+N_buf | ||
println("--- n = $n") | ||
tup = footup(n) | ||
@btime footup($n) | ||
|
||
dtup = DispatchedSet(tup) | ||
@btime DispatchedSet($tup) | ||
# @btime $dtup[Foo3()] # always results in 0.028 ns (0 allocations: 0 bytes) | ||
end | ||
end | ||
|
||
perf_dt(N, N_buf) | ||
perf_ds(N, N_buf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Performance timing | ||
|
||
See the `perf.jl` file for adjusting / experimenting with timings. Note that the output is limited for quick doc builds. | ||
|
||
```@example perf | ||
include("perf.jl") | ||
nothing | ||
``` |