Skip to content

Commit

Permalink
Merge pull request #198 from timholy/teh/precompiletools
Browse files Browse the repository at this point in the history
Migrate from SnoopPrecompile to PrecompileTools
  • Loading branch information
MilesCranmer authored Apr 26, 2023
2 parents 61ecbed + 641180a commit c8f65de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
ProgressBars = "49802e3a-d2f1-5c88-81d8-b72133a6f568"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
Expand All @@ -31,7 +31,7 @@ Optim = "0.19, 1.1"
Pkg = "1"
ProgressBars = "1.4"
Reexport = "1"
SnoopPrecompile = "1"
PrecompileTools = "1"
SpecialFunctions = "0.10.1, 1, 2"
StatsBase = "0.33"
SymbolicUtils = "0.19, ^1.0.5"
Expand Down
14 changes: 7 additions & 7 deletions src/precompile.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import SnoopPrecompile: @precompile_all_calls, @precompile_setup
import PrecompileTools: @compile_workload, @setup_workload

macro maybe_precompile_setup(mode, ex)
macro maybe_setup_workload(mode, ex)
precompile_ex = Expr(
:macrocall, Symbol("@precompile_setup"), LineNumberNode(@__LINE__), ex
:macrocall, Symbol("@setup_workload"), LineNumberNode(@__LINE__), ex
)
return quote
if $(esc(mode)) == :compile
Expand All @@ -15,9 +15,9 @@ macro maybe_precompile_setup(mode, ex)
end
end

macro maybe_precompile_all_calls(mode, ex)
macro maybe_compile_workload(mode, ex)
precompile_ex = Expr(
:macrocall, Symbol("@precompile_all_calls"), LineNumberNode(@__LINE__), ex
:macrocall, Symbol("@compile_workload"), LineNumberNode(@__LINE__), ex
)
return quote
if $(esc(mode)) == :compile
Expand All @@ -32,10 +32,10 @@ end

"""`mode=:precompile` will use `@precompile_*` directives; `mode=:compile` runs."""
function do_precompilation(; mode=:precompile)
@maybe_precompile_setup mode begin
@maybe_setup_workload mode begin
types = [Float32]
for T in types
@maybe_precompile_all_calls mode begin
@maybe_compile_workload mode begin
X = randn(T, 5, 100)
y = 2 * cos.(X[4, :]) + X[1, :] .^ 2 .- 2
options = SymbolicRegression.Options(;
Expand Down

0 comments on commit c8f65de

Please sign in to comment.