Skip to content

Commit be54421

Browse files
authored
Merge pull request #48 from vilterp/pv-profile-allocs-type-name-cache
alloc prof: memoize stringifying type name
2 parents df43527 + 5b54ef3 commit be54421

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/Allocs.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,17 @@ function pprof(alloc_profile::Profile.Allocs.AllocResults = Profile.Allocs.fetch
141141
end
142142
end
143143

144+
type_name_cache = Dict{Any,String}()
145+
146+
function get_type_name(type::Any)
147+
return get!(type_name_cache, type) do
148+
return "Alloc: $(type)"
149+
end
150+
end
151+
144152
function construct_location_for_type(typename)
145153
# TODO: Lol something less hacky than this:
146-
return maybe_add_location(StackFrame("Alloc: $(typename)", "nothing", 0))
154+
return maybe_add_location(StackFrame(get_type_name(typename), "nothing", 0))
147155
end
148156

149157
for sample in alloc_profile.allocs # convert the sample.stack to vector of location_ids

0 commit comments

Comments
 (0)