From a569f826850623acd56adb362e7c78e0751b2d8c Mon Sep 17 00:00:00 2001 From: roflmaostc Date: Tue, 22 Nov 2022 17:47:38 +0100 Subject: [PATCH] Add precompilation for FourierTools --- Project.toml | 3 ++- src/FourierTools.jl | 7 +++++++ src/precompilation.jl | 28 ++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/precompilation.jl diff --git a/Project.toml b/Project.toml index 5a7aa45..a161c00 100644 --- a/Project.toml +++ b/Project.toml @@ -13,9 +13,9 @@ NFFT = "efe261a4-0d2b-5849-be55-fc731d526b0d" PaddedViews = "5432bcbf-9aad-5242-b902-cca2824c8663" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" ShiftedArrays = "1277b4bf-5013-50f5-be3d-901d8477a67a" +SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c" [compat] - ChainRulesCore = "1, 1.0, 1.1" FFTW = "1.5" ImageTransformations = "0.9" @@ -25,6 +25,7 @@ NFFT = "0.11, 0.12, 0.13" PaddedViews = "0.5" Reexport = "1" ShiftedArrays = "2" +SnoopPrecompile = "1" Zygote = "0.6" julia = "1, 1.6, 1.7, 1.8" diff --git a/src/FourierTools.jl b/src/FourierTools.jl index b57250a..e30d537 100644 --- a/src/FourierTools.jl +++ b/src/FourierTools.jl @@ -8,6 +8,10 @@ using LinearAlgebra using IndexFunArrays using ChainRulesCore using NDTools + +using SnoopPrecompile + + @reexport using NFFT FFTW.set_num_threads(4) @@ -31,4 +35,7 @@ include("damping.jl") include("czt.jl") include("fractional_fourier_transform.jl") + +include("precompilation.jl") + end # module diff --git a/src/precompilation.jl b/src/precompilation.jl new file mode 100644 index 0000000..fa9084b --- /dev/null +++ b/src/precompilation.jl @@ -0,0 +1,28 @@ +# doesn't save too much but a little +@precompile_setup begin + img64 = abs.(randn(Float32, (4,4))) + img32 = abs.(randn(Float64, (4,4))) + imgCF64 = abs.(randn(ComplexF64, (4,4))) + imgCF32 = abs.(randn(ComplexF32, (4,4))) + + function f(img) + resample(img, (5,5)) + resample(img, (2,2)) + shift(img, (2,2)) + shift(img, (2,2)) + ft(img) + ffts(img) + ift(img) + iffts(img) + rotate(img, 1.1) + conv(img, img) + end + + @precompile_all_calls begin + f(img64) + f(img32) + f(imgCF64) + f(imgCF32) + end + +end