KristofferC / TimerOutputs.jl

Formatted output of timed sections in Julia
Other
659 stars 54 forks source link

RFC: Allow prev_timer to be set to nothing #131

Closed GregPlowman closed 3 years ago

GregPlowman commented 3 years ago

The circular self-reference of prev_timer field can cause problems in some circumstances. For example, exporting TimerOutput using JLD causes StackOverflowError. Workaround for #40

I realise this is an issue for JLD rather than TimerOutputs, so marking as RFC. However, it seems to provide a workaround with little impact on TimerOutputs.

Change type of prev_timer to Union{TimerOutput,Nothing} which allows setting it to nothing, breaking the circularity. It also seems consistent that prev_timer == nothing whenever prev_timer_label == "".

Before saving to JLD, set prev_timer to nothing.

KristofferC commented 3 years ago

Seems like a good idea. Thanks.