Skip to content

Commit

Permalink
Add pTq constructor analysis, fix 0 alloc case
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskawczynski committed Dec 12, 2021
1 parent cff50cd commit 0cdc6c4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
15 changes: 6 additions & 9 deletions perf/alloc_per_constructor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 5 additions & 1 deletion perf/allocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions perf/benchmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion perf/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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

0 comments on commit 0cdc6c4

Please sign in to comment.