Skip to content

Commit c34be8a

Browse files
chore: add a precompilation workload
1 parent be33b9b commit c34be8a

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Moshi = "2e0e35c7-a2e4-4343-998d-7ef72827ed2d"
2020
MultivariatePolynomials = "102ac46a-7ee4-5c85-9060-abc95bfdeaa3"
2121
MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
2222
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
23+
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
2324
ReadOnlyArrays = "988b38a3-91fc-5605-94a2-ee2116b3bd83"
2425
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
2526
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
@@ -61,6 +62,7 @@ MultivariatePolynomials = "0.5.12"
6162
MutableArithmetics = "1.6.5"
6263
NaNMath = "0.3, 1.1.2"
6364
OhMyThreads = "0.7"
65+
PrecompileTools = "1.2.1"
6466
ReadOnlyArrays = "0.2.0"
6567
ReverseDiff = "1"
6668
RuntimeGeneratedFunctions = "0.5.13"

src/SymbolicUtils.jl

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import DynamicPolynomials as DP
3434
import MutableArithmetics as MA
3535
import LinearAlgebra
3636
import SparseArrays: SparseMatrixCSC, findnz, sparse
37+
import PrecompileTools
3738

3839
macro manually_scope(val, expr, is_forced = false)
3940
@assert Meta.isexpr(val, :call)
@@ -101,7 +102,9 @@ include("small_array.jl")
101102
export istree, operation, arguments, sorted_arguments, iscall, unwrap_const
102103
# Sym, Term,
103104
# Add, Mul and Pow
104-
include("types.jl")
105+
PrecompileTools.@recompile_invalidations begin
106+
include("types.jl")
107+
end
105108

106109
include("printing.jl")
107110

@@ -151,4 +154,26 @@ include("substitute.jl")
151154

152155
include("code.jl")
153156

157+
PrecompileTools.@setup_workload begin
158+
PrecompileTools.@compile_workload begin
159+
@syms x y f(t) q[1:5]
160+
x + y
161+
x * y
162+
x / y
163+
x ^ y
164+
x ^ 5
165+
6 ^ x
166+
x - y
167+
-y
168+
f(x)
169+
(5x / 5)
170+
show(devnull, x ^ 2 + y * x + y / 3x)
171+
expand((x + y) ^ 2)
172+
simplify(x ^ (1//2) + (sin(x) ^ 2 + cos(x) ^ 2) + 2(x + y) - x - y)
173+
substitute(x + 2y + sin(x), Dict(x => y); fold = false)
174+
substitute(x + 2y + sin(x), Dict(x => 1); fold = true)
175+
q[1]
176+
end
177+
end
178+
154179
end # module

0 commit comments

Comments
 (0)