-
Notifications
You must be signed in to change notification settings - Fork 3
Add benchmarks #30
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
Merged
Merged
Add benchmarks #30
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,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"] | ||
langestefan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| steps: | ||
| - uses: MilesCranmer/AirspeedVelocity.jl@action-v1 | ||
| with: | ||
| julia-version: ${{ matrix.julia-version }} | ||
| exeflags: "--threads=auto" | ||
This file contains hidden or 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,6 +1,8 @@ | ||
| *.jl.*.cov | ||
| *.jl.cov | ||
| *.jl.mem | ||
| **/*.json | ||
| **/*.tmp | ||
| *.rej | ||
| .DS_Store | ||
| .benchmarkci | ||
|
|
||
This file contains hidden or 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 hidden or 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,7 @@ | ||
| [deps] | ||
| BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" | ||
| Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" | ||
| SolarPosition = "5b9d1343-a731-5a90-8730-7bf8d89bf3eb" | ||
|
|
||
| [sources] | ||
| SolarPosition = { path = ".." } |
This file contains hidden or 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,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") | ||
langestefan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.