diff --git a/Project.toml b/Project.toml index 82a8483..8485790 100644 --- a/Project.toml +++ b/Project.toml @@ -6,12 +6,14 @@ version = "1.3.0" DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e" MATLAB = "10e44e05-a98a-55b3-a45b-ba969058deb6" ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" +PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" [compat] DiffEqBase = "6.122" MATLAB = "0.8, 0.9" ModelingToolkit = "8, 9, 10, 11" +PrecompileTools = "1" Reexport = "0.2, 1.0" julia = "1.6" diff --git a/src/MATLABDiffEq.jl b/src/MATLABDiffEq.jl index 7d61448..741868e 100644 --- a/src/MATLABDiffEq.jl +++ b/src/MATLABDiffEq.jl @@ -3,6 +3,7 @@ module MATLABDiffEq using Reexport @reexport using DiffEqBase using MATLAB, ModelingToolkit +using PrecompileTools # Handle ModelingToolkit API changes: states -> unknowns if isdefined(ModelingToolkit, :unknowns) @@ -152,4 +153,33 @@ function buildDEStats(solverstats::Dict) destats end +@setup_workload begin + # Precompile algorithm struct instantiations and buildDEStats + @compile_workload begin + # Instantiate algorithm structs - this precompiles their constructors + _ = ode23() + _ = ode45() + _ = ode113() + _ = ode23s() + _ = ode23t() + _ = ode23tb() + _ = ode15s() + _ = ode15i() + + # Precompile buildDEStats with typical MATLAB stats dictionaries + test_stats = Dict{String, Any}( + "nfevals" => 100, + "nfailed" => 5, + "nsteps" => 95, + "nsolves" => 50, + "npds" => 10, + "ndecomps" => 8 + ) + _ = buildDEStats(test_stats) + + # Also precompile with missing keys (common case) + _ = buildDEStats(Dict{String, Any}()) + end +end + end # module