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
18 changes: 18 additions & 0 deletions .github/workflows/BenchmarkPRTarget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Benchmark PR
on:
pull_request_target:
branches: [main]
permissions:
pull-requests: write # needed to post comments

jobs:
bench:
runs-on: ubuntu-latest
strategy:
matrix:
julia-version: ["lts", "1", "pre"]
steps:
- uses: MilesCranmer/AirspeedVelocity.jl@action-v1
with:
julia-version: ${{ matrix.julia-version }}
exeflags: "--threads=auto"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*.jl.*.cov
*.jl.cov
*.jl.mem
**/*.json
**/*.tmp
*.rej
.DS_Store
.benchmarkci
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.2.3"
authors = ["Stefan de Lange"]

[workspace]
projects = ["test", "docs"]
projects = ["test", "docs", "benchmark", "examples"]

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
7 changes: 7 additions & 0 deletions benchmark/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
SolarPosition = "5b9d1343-a731-5a90-8730-7bf8d89bf3eb"

[sources]
SolarPosition = { path = ".." }
90 changes: 90 additions & 0 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
"""
Benchmarks for SolarPosition.jl

Compatible with AirspeedVelocity.jl for benchmarking across package versions.

Run locally with:
benchpkg SolarPosition --rev=main,dirty

Or use the Julia API:
using BenchmarkTools
include("benchmarks/benchmarks.jl")
run(SUITE)
"""

using BenchmarkTools
using SolarPosition
using Dates

# ============================================================================
# Benchmark Suite
# ============================================================================

const SUITE = BenchmarkGroup()

# ============================================================================
# Configuration
# ============================================================================

# Test observer location
const OBSERVER = Observer(51.5074, -0.1278, 11.0) # London

# Standard test datetime
const TEST_DT = DateTime(2024, 6, 21, 12, 0, 0)

# Generate test time vectors of different sizes
function generate_times(n::Int)
return collect(DateTime(2024, 1, 1):Hour(1):(DateTime(2024, 1, 1)+Hour(n-1)))
end

# Available algorithms to benchmark
const POSITION_ALGORITHMS = Dict(
"PSA" => PSA(2020),
"NOAA" => NOAA(),
"Walraven" => Walraven(),
"USNO" => USNO(),
"SPA" => SPA(),
)

const REFRACTION_ALGORITHMS = Dict(
"NoRefraction" => NoRefraction(),
"BENNETT" => BENNETT(),
"ARCHER" => ARCHER(),
"MICHALSKY" => MICHALSKY(),
"SG2" => SG2(),
)

# ============================================================================
# Single Position Benchmarks
# ============================================================================

SUITE["single"] = BenchmarkGroup()

for (name, algo) in POSITION_ALGORITHMS
SUITE["single"][name] = @benchmarkable(solar_position($(OBSERVER), $TEST_DT, $algo))
end

# ============================================================================
# Vector Position Benchmarks (multiple timestamps)
# ============================================================================

SUITE["vector"] = BenchmarkGroup()

for n in [100, 1_000, 10_000, 100_000]
times = generate_times(n)
for (name, algo) in POSITION_ALGORITHMS
SUITE["vector"]["n=$n,$name"] =
@benchmarkable(solar_position($(OBSERVER), $times, $algo))
end
end

# ============================================================================
# Refraction Algorithm Benchmarks
# ============================================================================

SUITE["refraction"] = BenchmarkGroup()

for (name, algo) in REFRACTION_ALGORITHMS
SUITE["refraction"][name] =
@benchmarkable(solar_position($(OBSERVER), $TEST_DT, PSA(), $algo))
end
Loading