diff --git a/perf/alloc_per_constructor.jl b/perf/alloc_per_constructor.jl index 44d8700e..af98187c 100644 --- a/perf/alloc_per_constructor.jl +++ b/perf/alloc_per_constructor.jl @@ -8,15 +8,12 @@ include("common.jl") constructor = ENV["ALLOCATION_CONSTRUCTOR"] @info "Recording allocations for $constructor" - -if constructor == "ρeq" - thermo_state = thermo_state_ρeq_newton -else -end -if constructor == "pθq" - thermo_state = thermo_state_pθq -else -end +thermo_state_map = Dict( + "ρeq" => thermo_state_ρeq_newton, + "pθq" => thermo_state_pθq, + "pTq" => thermo_state_pTq, +) +thermo_state = thermo_state_map[constructor] thermo_state() # compile first Profile.clear_malloc_data() diff --git a/perf/allocs.jl b/perf/allocs.jl index 85d35c55..84264b8c 100644 --- a/perf/allocs.jl +++ b/perf/allocs.jl @@ -20,7 +20,7 @@ all_dirs_to_monitor = [ # https://github.com/jheinen/GR.jl/issues/278#issuecomment-587090846 ENV["GKSwstype"] = "nul" -constructors = ["ρeq", "pθq"] +constructors = ["ρeq", "pθq", "pTq"] allocs = Dict() for constructor in constructors @@ -101,6 +101,10 @@ function plot_allocs(constructor, allocs_per_case, n_unique_bytes) end all_bytes = all_bytes ./ 10^3 + if isempty(all_bytes) + @info "$constructor: 0 allocations! 🎉" + return nothing + end max_bytes = maximum(all_bytes) @info "$constructor: $all_bytes" xtick_name(filename, linenumber) = "$filename, line number: $linenumber" diff --git a/perf/benchmark.jl b/perf/benchmark.jl index 3ebb3fb9..cb7877bd 100644 --- a/perf/benchmark.jl +++ b/perf/benchmark.jl @@ -10,5 +10,7 @@ include("common.jl") show(stdout, MIME("text/plain"), trial) trial = BenchmarkTools.@benchmark $thermo_state_pθq() show(stdout, MIME("text/plain"), trial) + trial = BenchmarkTools.@benchmark $thermo_state_pTq() + show(stdout, MIME("text/plain"), trial) end diff --git a/perf/common.jl b/perf/common.jl index 841ea8b3..8ccf9ae3 100644 --- a/perf/common.jl +++ b/perf/common.jl @@ -19,7 +19,7 @@ const param_set = EarthParameterSet() ArrayType = Array{Float64} profiles = TD.TestedProfiles.PhaseEquilProfiles(param_set, ArrayType) -UnPack.@unpack e_int, ρ, p, θ_liq_ice, q_tot = profiles +UnPack.@unpack e_int, T, ρ, p, θ_liq_ice, q_tot = profiles function thermo_state_ρeq_newton() ts = @@ -57,3 +57,7 @@ end function thermo_state_pθq() ts = TD.PhaseEquil_pθq.(param_set, p, θ_liq_ice, q_tot) end + +function thermo_state_pTq() + ts = TD.PhaseEquil_pTq.(param_set, p, T, q_tot) +end