From 52977c4499800010986a92260a307f5bbb2b9599 Mon Sep 17 00:00:00 2001 From: JamesWrigley Date: Sun, 6 Apr 2025 13:28:18 +0200 Subject: [PATCH] Add a precompilation workload --- Project.toml | 2 ++ src/LsqFit.jl | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Project.toml b/Project.toml index 100d891..f591bc0 100644 --- a/Project.toml +++ b/Project.toml @@ -7,6 +7,7 @@ Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" NLSolversBase = "d41bc354-129a-5804-8e4c-c37616107c6c" +PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" StatsAPI = "82ae8749-77ed-4fe6-ae5f-f523153014b0" @@ -14,6 +15,7 @@ StatsAPI = "82ae8749-77ed-4fe6-ae5f-f523153014b0" Distributions = "0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25" ForwardDiff = "0.10" NLSolversBase = "7.5" +PrecompileTools = "1.2.1" StatsAPI = "1" julia = "1.6" diff --git a/src/LsqFit.jl b/src/LsqFit.jl index 622eb64..53d761f 100644 --- a/src/LsqFit.jl +++ b/src/LsqFit.jl @@ -32,4 +32,26 @@ include("geodesic.jl") include("levenberg_marquardt.jl") include("curve_fit.jl") +import PrecompileTools: @compile_workload + +@compile_workload begin + model(x, p) = @. p[1] * x + p[2] + + local fit + for T in (Float32, Float64) + xdata = T.(1:100) + ydata = model(xdata, T[1.0, 1.0]) + p0 = T[0.8, 0.8] + + for ad in (:finite, :finiteforward, :forwarddiff) + fit = curve_fit(model, xdata, ydata, p0; autodiff=ad) + end + end + + stderror(fit) + margin_error(fit) + confint(fit) + vcov(fit) +end + end