JuliaLang / AllocCheck.jl

AllocCheck
Other
209 stars 8 forks source link

[Feature] Warning output instead of error #44

Open muendlein opened 8 months ago

muendlein commented 8 months ago

In the current example allocations will trigger an error. However this may not always be desired, thus I propose a configuration option for a warning instead.

julia> using AllocCheck

julia> @check_allocs multiply(x,y) = x * y
multiply (generic function with 1 method)

julia> multiply(1.5, 2.5) # call automatically checked for allocations
3.75

julia> multiply(rand(3,3), rand(3,3)) # result matrix requires an allocation
ERROR: @check_alloc function encountered 1 errors (1 allocations / 0 dynamic dispatches)
carstenbauer commented 8 months ago

Note that the advantage of errors is that you get a stack trace.

aviatesk commented 8 months ago

IIUC, it should be able to show stacktraces even if we don't raise an error. We can customize show(::IO, ::AllocCheckAnalysisResult) to include stacktrace into the rendered output.