From 44e2b13940ed0e360e288b467b0a8947950f82b1 Mon Sep 17 00:00:00 2001 From: Kyungdahm Yun Date: Tue, 23 Apr 2024 14:18:24 +0900 Subject: [PATCH] Use PrecompileTools --- Project.toml | 2 ++ src/Cropbox.jl | 2 ++ src/precompile.jl | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 src/precompile.jl diff --git a/Project.toml b/Project.toml index 36755345..587ff363 100644 --- a/Project.toml +++ b/Project.toml @@ -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" @@ -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" diff --git a/src/Cropbox.jl b/src/Cropbox.jl index fe0607f1..dfac6456 100644 --- a/src/Cropbox.jl +++ b/src/Cropbox.jl @@ -34,4 +34,6 @@ include("util/plot.jl") include("util/visualize.jl") include("util/manipulate.jl") +include("precompile.jl") + end diff --git a/src/precompile.jl b/src/precompile.jl new file mode 100644 index 00000000..41df5daa --- /dev/null +++ b/src/precompile.jl @@ -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