|
| 1 | +# Precompilation workload for DataDrivenDiffEq |
| 2 | +# This file contains code that will be executed during precompilation to |
| 3 | +# improve startup time and time-to-first-execution (TTFX) |
| 4 | + |
| 5 | +using PrecompileTools |
| 6 | + |
| 7 | +@setup_workload begin |
| 8 | + # Set up minimal test data and variables |
| 9 | + # Note: We avoid heavy computations here, just trigger code paths |
| 10 | + @compile_workload begin |
| 11 | + # Create symbolic variables for Basis construction |
| 12 | + # This is the main TTFX bottleneck (33+ seconds without precompilation) |
| 13 | + @variables x y t |
| 14 | + |
| 15 | + # Precompile Basis construction - the most important operation |
| 16 | + # Use simple expressions to minimize precompilation time |
| 17 | + basis = Basis([x, y, x * y, x^2, y^2], [x, y]) |
| 18 | + |
| 19 | + # Precompile basis evaluation (both scalar and vector forms) |
| 20 | + u_test = [1.0, 2.0] |
| 21 | + p_test = Float64[] |
| 22 | + t_test = 0.0 |
| 23 | + _ = basis(u_test, p_test, t_test) |
| 24 | + |
| 25 | + # Precompile problem constructors |
| 26 | + X = randn(2, 10) |
| 27 | + Y = randn(2, 10) |
| 28 | + t_span = collect(range(0.0, 1.0, length = 10)) |
| 29 | + |
| 30 | + # DirectDataDrivenProblem |
| 31 | + prob_direct = DirectDataDrivenProblem(X, Y) |
| 32 | + |
| 33 | + # DiscreteDataDrivenProblem |
| 34 | + prob_discrete = DiscreteDataDrivenProblem(X) |
| 35 | + |
| 36 | + # ContinuousDataDrivenProblem (uses collocation which takes time) |
| 37 | + prob_cont = ContinuousDataDrivenProblem(X, t_span) |
| 38 | + |
| 39 | + # Precompile basis generators |
| 40 | + poly_basis = polynomial_basis([x, y], 2) |
| 41 | + mono_basis = monomial_basis([x, y], 2) |
| 42 | + |
| 43 | + # Precompile basis evaluation with problem |
| 44 | + _ = basis(prob_direct) |
| 45 | + end |
| 46 | +end |
0 commit comments