diff --git a/Project.toml b/Project.toml index a0c40a7..08c2cf1 100644 --- a/Project.toml +++ b/Project.toml @@ -35,15 +35,14 @@ Timers = "0.1.5" julia = "1.10" [extras] +ControlPlots = "23c2ee80-7a9e-4350-b264-8e670f12517c" HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" KiteModels = "b94af626-7959-4878-9336-2adc27959007" KitePodModels = "9de5dc81-f971-414a-927b-652b2f41c539" PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d" -Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee" StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test", "KiteModels", "PyPlot", "KitePodModels", "PackageCompiler", "Plots"] +test = ["Test", "KiteModels", "KitePodModels", "PackageCompiler", "ControlPlots"] diff --git a/examples/depower.jl b/examples/depower.jl index d27dadc..da3166c 100644 --- a/examples/depower.jl +++ b/examples/depower.jl @@ -64,9 +64,10 @@ integrator = KiteModels.init_sim!(kps4, stiffness_factor=0.5, prn=STATISTIC) av_steps = simulate(integrator, STEPS, log=SAVE_PNG) if PLOT_PERFORMANCE - using Plots - plot(range(0.5,TIME,step=0.5), time_vec, ylabel="CPU time [%]", xlabel="Simulation time [s]", legend=false) - savefig("performance.png") + using ControlPlots + p = plot(range(0.25,TIME,step=0.25), time_vec; ylabel="CPU time [%]", xlabel="Simulation time [s]") + display(p) + plt.savefig("performance.png") end # mean with :Dense integrator: 6.66% CPU time, 15 times realtime # mean with :GMRES integrator: 1.96% CPU time, 51 times realtime diff --git a/examples/depower_bench_video.jl b/examples/depower_bench_video.jl index 6b143f4..fabd3ec 100644 --- a/examples/depower_bench_video.jl +++ b/examples/depower_bench_video.jl @@ -69,9 +69,8 @@ integrator = KiteModels.init_sim!(kps4, stiffness_factor=0.5, prn=STATISTIC) av_steps = simulate(integrator, STEPS, log=SAVE_PNG) if PLOT_PERFORMANCE - using Plots - plot(range(0.5,TIME,step=0.5), time_vec, ylabel="CPU time [%]", xlabel="Simulation time [s]", legend=false) - savefig("performance.png") + using ControlPlots + plot(range(0.5,TIME,step=0.5), time_vec; ylabel="CPU time [%]", xlabel="Simulation time [s]") end # mean with :Dense integrator: 6.66% CPU time, 15 times realtime # mean with :GMRES integrator: 1.96% CPU time, 51 times realtime diff --git a/examples/depower_simple.jl b/examples/depower_simple.jl index ccba331..481bdee 100644 --- a/examples/depower_simple.jl +++ b/examples/depower_simple.jl @@ -41,10 +41,13 @@ function simulate(integrator, steps) set_depower_steering(kps4.kcu, 0.35, 0.0) end t_sim = @elapsed KiteModels.next_step!(kps4, integrator; set_speed=0, dt=dt) + if i==1 + t_sim = 0 + end t_gc = 0.0 - # if t_sim < 0.08*dt - # t_gc = @elapsed GC.gc(false) - # end + if t_sim < 0.08*dt + t_gc = @elapsed GC.gc(false) + end t_show = 0.0 if mod(i, TIME_LAPSE_RATIO) == 0 || i == steps t_show = @elapsed update_system(viewer, SysState(kps4); scale = 0.08, kite_scale=3.0) @@ -101,13 +104,13 @@ toc() play() stop(viewer) if PLOT_PERFORMANCE - include("plot.jl") + using ControlPlots if false plotx(range(dt,TIME,step=dt), time_vec_gc, time_vec_sim, time_vec_sim.+time_vec_gc; - labels=["GC time","sim_time","total_time"], + ylabels=["GC time","sim_time","total_time"], fig="depower_simple_timing") else - plot1(range(3*TIME_LAPSE_RATIO*dt,TIME,step=dt*TIME_LAPSE_RATIO), time_vec_tot[3:end], + plot(range(3*TIME_LAPSE_RATIO*dt,TIME,step=dt*TIME_LAPSE_RATIO), time_vec_tot[3:end]; ylabel="time per frame [ms]") end end diff --git a/examples/joystick.jl b/examples/joystick.jl index e963c38..fc85399 100644 --- a/examples/joystick.jl +++ b/examples/joystick.jl @@ -108,6 +108,7 @@ on(jsbuttons.btn2) do val; if val stop(viewer) end; end play() stop(viewer) -using Plots -plot(range(5*TIME_LAPSE_RATIO*dt,steps*dt,step=dt*TIME_LAPSE_RATIO), time_vec_tot[5:steps], xlabel="Simulation time [s]", ylabel="time per frame [ms]", label="time_tot") -plot!(range(5*TIME_LAPSE_RATIO*dt,steps*dt,step=dt*TIME_LAPSE_RATIO), time_vec_gc[5:steps], label="time_gc") +using ControlPlots +plot(range(5*TIME_LAPSE_RATIO*dt,steps*dt,step=dt*TIME_LAPSE_RATIO), [time_vec_tot[5:steps], time_vec_gc[5:steps]]; + xlabel="Simulation time [s]", ylabel="time per frame [ms]", labels=["time total", "time_gc"]) + diff --git a/examples/plot.jl b/examples/plot.jl deleted file mode 100644 index 219ad0d..0000000 --- a/examples/plot.jl +++ /dev/null @@ -1,62 +0,0 @@ -using Pkg -if ! ("Plots" ∈ keys(Pkg.project().dependencies)) - using TestEnv; TestEnv.activate() -end -import PyPlot as plt - -function plot1(X, Y; xlabel="time [s]", ylabel="", fig="") - if fig != "" - plt.figure(fig) - end - plt.xlabel(xlabel, fontsize=14); - plt.ylabel(ylabel, fontsize=14); - plt.plot(X, Y; label=ylabel) - plt.grid(true) - nothing -end - -function plotxy(X, Y; xlabel="", ylabel, fig="") - if fig != "" - plt.figure(fig) - end - p = plt.plot(X, Y) - plt.xlabel(xlabel, fontsize=14); - plt.ylabel(ylabel, fontsize=14); - plt.grid(true) - plt.tight_layout() - nothing -end - -function plotx(X, Y...; labels=nothing, fig="", title="") - len=length(Y) - fig_ = plt.figure(fig, figsize=(8, len*2)) - i=1 - ax=[] - for y in Y - subplot=100len+10+i - if i==1 - push!(ax, plt.subplot(subplot)) - else - push!(ax, plt.subplot(subplot, sharex=ax[1])) - end - if i==1 - plt.suptitle(title, fontsize=14) # Super title - end - if ! isnothing(labels) - lbl=labels[i] - else - lbl="" - end - plt.plot(X, y, label=lbl) - plt.ylabel(lbl, fontsize=14); - plt.grid(true) - if i < len - plt.setp(ax[i].get_xticklabels(), visible=false) - end - i+=1 - end - plt.xlabel("time [s]", fontsize=14) - plt.xlim(0, X[end]) - plt.tight_layout() - nothing -end diff --git a/examples/reelout.jl b/examples/reelout.jl index 981a70a..b128724 100644 --- a/examples/reelout.jl +++ b/examples/reelout.jl @@ -67,10 +67,10 @@ integrator = KiteModels.init_sim!(kps4, stiffness_factor=0.5, prn=STATISTIC) av_steps = simulate(integrator, STEPS, log=SAVE_PNG) if PLOT_PERFORMANCE - using Plots - plt=plot(range(0.25,TIME,step=0.25), time_vec, ylabel="CPU time [%]", xlabel="Simulation time [s]", legend=false) - savefig("performance.png") - display(plt) + using ControlPlots + p = plot(range(0.25,TIME,step=0.25), time_vec; ylabel="CPU time [%]", xlabel="Simulation time [s]") + plt.savefig("performance.png") + display(p) end # mean with :Dense integrator: 6.66% CPU time, 15 times realtime # mean with :GMRES integrator: 1.96% CPU time, 51 times realtime diff --git a/examples/steering_bench_video.jl b/examples/steering_bench_video.jl index e965b46..98e7296 100644 --- a/examples/steering_bench_video.jl +++ b/examples/steering_bench_video.jl @@ -73,6 +73,6 @@ integrator = KiteModels.init_sim!(kps4, stiffness_factor=0.5, prn=STATISTIC) av_steps = simulate(integrator, STEPS, log=SAVE_PNG) if PLOT_PERFORMANCE - using Plots - plot(range(0.5,45,step=0.5), time_vec, ylabel="CPU time [%]", xlabel="Simulation time [s]", legend=false) + using ControlPlots + plot(range(0.1,TIME,step=0.1), time_vec; ylabel="CPU time [%]", xlabel="Simulation time [s]") end diff --git a/performance.png b/performance.png index 322826c..b092edb 100644 Binary files a/performance.png and b/performance.png differ diff --git a/test/create_sys_image.jl b/test/create_sys_image.jl deleted file mode 100644 index 25df26f..0000000 --- a/test/create_sys_image.jl +++ /dev/null @@ -1,17 +0,0 @@ -# activate the test environment if needed -using Pkg -if ! ("PackageCompiler" ∈ keys(Pkg.project().dependencies)) - using TestEnv; TestEnv.activate() -end -@info "Loading packages ..." -using StaticArrays, LinearAlgebra, Parameters, KiteUtils, KitePodModels, KiteModels, GLMakie, Plots -using PackageCompiler - -@info "Creating sysimage ..." -push!(LOAD_PATH,joinpath(pwd(),"src")) - -PackageCompiler.create_sysimage( - [:StaticArrays, :Parameters, :KiteUtils, :KitePodModels, :KiteModels, :GLMakie, :Plots]; - sysimage_path="kps-image_tmp.so", - precompile_execution_file=joinpath("test", "test_for_precompile.jl") -) \ No newline at end of file diff --git a/test/update_packages.jl b/test/update_packages.jl deleted file mode 100644 index 7daf50d..0000000 --- a/test/update_packages.jl +++ /dev/null @@ -1,5 +0,0 @@ -@info "Updating packages ..." -using Pkg -Pkg.instantiate() -Pkg.update() -Pkg.precompile()