Skip to content

Commit

Permalink
Use PrecompileTools
Browse files Browse the repository at this point in the history
  • Loading branch information
tomyun committed Apr 23, 2024
1 parent a927fcd commit 44e2b13
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ JuliaInterpreter = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
PolynomialRoots = "3a141323-8675-5d76-9d11-e1df1406c778"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Expand Down Expand Up @@ -49,6 +50,7 @@ Interpolations = "0.14, 0.15"
JuliaInterpreter = "0.9"
MacroTools = "0.5"
PolynomialRoots = "1"
PrecompileTools = "1"
ProgressMeter = "1.6"
QuadGK = "2"
Setfield = "1"
Expand Down
2 changes: 2 additions & 0 deletions src/Cropbox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ include("util/plot.jl")
include("util/visualize.jl")
include("util/manipulate.jl")

include("precompile.jl")

end
22 changes: 22 additions & 0 deletions src/precompile.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using PrecompileTools: @setup_workload, @compile_workload

@setup_workload begin
@system S(Controller) begin
a => 1 ~ preserve
b(a) ~ track
c(b) ~ accumulate
end
c = @config

@compile_workload begin
r = simulate(S, config=c)
simulate(S, configs=[c])
visualize(r, :time, :c; backend=:UnicodePlots)
visualize(r, :time, :c; backend=:Gadfly)[] |> Cropbox.Gadfly.SVGJS()
visualize(r, :time, :c; kind=:line, backend=:Gadfly)' |> Cropbox.Gadfly.SVG()
visualize(S, :time, :c; backend=:UnicodePlots)
visualize(S, :time, :c; backend=:Gadfly)[] |> Cropbox.Gadfly.SVGJS()
r |> display
display(MIME("text/html"), r)
end
end

0 comments on commit 44e2b13

Please sign in to comment.