Skip to content

Commit 4c2cdca

Browse files
committed
Add profiling script
1 parent e823619 commit 4c2cdca

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

examples/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
77
OhMyThreads = "67456a42-1dca-4109-a031-0a68de7e3ad5"
88
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
99
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
10+
ProfileView = "c46f51b8-102a-5cf2-8d2c-8597cb0e0da7"
1011
SolarPosition = "5b9d1343-a731-5a90-8730-7bf8d89bf3eb"
1112
StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
1213

examples/profiling.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""Profiling example for SolarPosition.jl using ProfileView."""
2+
3+
using Pkg
4+
Pkg.activate(@__DIR__)
5+
Pkg.instantiate()
6+
7+
using Dates
8+
using SolarPosition
9+
10+
# define observer location (latitude, longitude, altitude in meters)
11+
obs = Observer(52.358134610343214, 4.881269505489815, 0.0) # Van Gogh Museum
12+
13+
# a whole year of hourly timestamps for profiling
14+
times = collect(DateTime(2023):Minute(1):DateTime(2024))
15+
16+
# warm up the function to compile
17+
solar_position(obs, times, PSA())
18+
19+
# profile the PSA algorithm with multiple iterations for better sampling
20+
@profview for _ = 1:1000
21+
solar_position(obs, times, PSA())
22+
end

0 commit comments

Comments
 (0)