Skip to content

Commit ce858da

Browse files
committed
add benchmark
1 parent 965269b commit ce858da

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

bench/Project.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[deps]
2+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
3+
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
4+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
5+
PSFModels = "9ba017d1-7760-46cd-84a3-1e79e9ae9ddc"
6+
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
7+
8+
[compat]
9+
BenchmarkTools = "0.5"
10+
CSV = "0.8"
11+
PSFModels = "0.1.1"
12+
PyCall = "1"

bench/bench.jl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using BenchmarkTools
2+
using CSV
3+
using DataFrames
4+
using PSFModels: Gaussian, AiryDisk, Moffat
5+
using PyCall
6+
7+
apm = pyimport("astropy.modeling.functional_models")
8+
9+
@info "Starting PSF evaluation benchmark"
10+
11+
julia_models = [
12+
Gaussian((5.3, 4.7)),
13+
AiryDisk(12.7),
14+
Moffat(8.1)
15+
]
16+
astropy_models = [
17+
apm.Gaussian2D(x_stddev=5.3, y_stddev=4.7),
18+
apm.AiryDisk2D(radius=12.7),
19+
apm.Moffat2D(gamma=8.1, alpha=-1)
20+
]
21+
22+
names = ("Gaussian", "AiryDisk", "Moffat")
23+
jl_times = []
24+
py_times = []
25+
26+
for (jl_mod, py_mod, name) in zip(julia_models, astropy_models, names)
27+
jl_time = @belapsed $jl_mod(0.5, 0.7)
28+
push!(jl_times, jl_time)
29+
30+
py_time = @belapsed $py_mod(0.5, 0.7)
31+
push!(py_times, py_time)
32+
33+
@info "$name" PSFModels=jl_time astropy=py_time
34+
end
35+
36+
filename = joinpath(@__DIR__, "results.csv")
37+
DataFrame(name=names, psfmodels=jl_times, astropy=py_times) |> CSV.write(filename)
38+
39+
40+
@info "Finished PSF evaluation benchmark. Results saved to $filename"
41+
42+
nothing

bench/results.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name,psfmodels,astropy
2+
"(""Gaussian"", ""AiryDisk"", ""Moffat"")",1.5927855711422846e-8,0.000165969
3+
"(""Gaussian"", ""AiryDisk"", ""Moffat"")",3.7001009081735617e-8,0.000135154
4+
"(""Gaussian"", ""AiryDisk"", ""Moffat"")",1.192685370741483e-8,0.000134448

0 commit comments

Comments
 (0)