Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/test_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,16 @@ const __MAX_ARGS_ALLOCS = 10
return Base.gc_alloc_count(diff)
end
end
# Needs a special case when `f` itself is a type constructor
function count_allocs(::Type{F}, $(sigs...)) where {F,$(types...)}
test_hook(count_allocs, F, $(args...)) do
stats = Base.gc_num()
@noinline clos = () -> F($(args...))
clos()
diff = Base.GC_Diff(Base.gc_num(), stats)
return Base.gc_alloc_count(diff)
end
end
end
eval(fexpr)
end
Expand Down
Loading