Skip to content
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
29 changes: 29 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Benchmark this PR

on:
pull_request:
branches: [main]
paths-ignore: ['docs/**']

permissions:
pull-requests: write
contents: read

jobs:
benchmark:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
version: ["1", "lts"]
env:
# Force consistent Julia depot path for self-hosted runners
JULIA_DEPOT_PATH: ~/.julia
steps:
- uses: MilesCranmer/AirspeedVelocity.jl@action-v1
with:
julia-version: ${{ matrix.version }}
script: "benchmark/benchmarks.jl"
extra-pkgs: ""
job-summary: true
53 changes: 53 additions & 0 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using FunctionWrappersWrappers, BenchmarkTools

const SUITE = BenchmarkGroup()

# FunctionWrappersWrapper wraps one function across multiple argument signatures
argtypes = (Tuple{Float64, Float64}, Tuple{Int, Int})
rettypes = (Float64, Int)

# =============================================================================
# Construction
# =============================================================================

SUITE["construct"] = BenchmarkGroup()

SUITE["construct"]["default"] = @benchmarkable FunctionWrappersWrapper(
+, $argtypes, $rettypes
)
SUITE["construct"]["dictcache"] = @benchmarkable FunctionWrappersWrapper(
+, $argtypes, $rettypes; cache = DictCache()
)
SUITE["construct"]["no_policy"] = @benchmarkable FunctionWrappersWrapper(
+, $argtypes, $rettypes; policy = AllowAll()
)

# =============================================================================
# Calls and metadata
# =============================================================================

SUITE["call"] = BenchmarkGroup()

fww = FunctionWrappersWrapper(+, argtypes, rettypes)
fww_dict = FunctionWrappersWrapper(+, argtypes, rettypes; cache = DictCache())

SUITE["call"]["float_args"] = @benchmarkable $fww(1.0, 2.0)
SUITE["call"]["int_args"] = @benchmarkable $fww(1, 2)
SUITE["call"]["dictcache"] = @benchmarkable $fww_dict(1.0, 2.0)

SUITE["call"]["unwrap"] = @benchmarkable unwrap($fww)
SUITE["call"]["wrapped_signatures"] = @benchmarkable wrapped_signatures($fww)
SUITE["call"]["wrapped_return_types"] = @benchmarkable wrapped_return_types($fww)

# =============================================================================
# Vector of wrappers
# =============================================================================

SUITE["vector"] = BenchmarkGroup()

fww1 = FunctionWrappersWrapper(sin, (Tuple{Float64},), (Float64,))
FWW1 = typeof(fww1)
fww_vec = FWW1[sin, tan, log]

SUITE["vector"]["getindex_call"] = @benchmarkable $fww_vec[1](0.5)
SUITE["vector"]["construct"] = @benchmarkable $FWW1[sin, tan, log]
Loading