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

Add perf timings in docs #24

Merged
merged 1 commit into from
Mar 18, 2021
Merged
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
1 change: 1 addition & 0 deletions docs/Project.toml
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"
3 changes: 2 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ makedocs(
modules = [DispatchedTuples],
pages = Any[
"Home" => "index.md",
"Performance" => "performance.md",
"Performance introspection" => "performance.md",
"Performance timing" => "performance_timing.md",
"API" => "api.md",
],
)
Expand Down
48 changes: 48 additions & 0 deletions docs/src/perf.jl
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)
2 changes: 1 addition & 1 deletion docs/src/performance.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Performance
# Performance introspection

The performance of `DispatchedTuple`s should scale similar to the performance of ordinary tuples (good with small tuples, but expensive with larger ones).

Expand Down
8 changes: 8 additions & 0 deletions docs/src/performance_timing.md
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
```