timer_utils
moment_kinetics.timer_utils
— ModuleUtilities for timing functions or blocks of code
moment_kinetics.timer_utils.global_timer
— ConstantGlobal object used to collect timings of various parts of the code
moment_kinetics.timer_utils.timer_names_all_ranks_dfns
— ConstantNested SortedDict with the names of all timers that have been created on any MPI rank and added to the dfns output file.
moment_kinetics.timer_utils.timer_names_all_ranks_moments
— ConstantNested SortedDict with the names of all timers that have been created on any MPI rank and added to the moments output file.
moment_kinetics.timer_utils.TimerNamesDict
— Typemoment_kinetics.timer_utils.format_global_timer
— Methodformat_global_timer(; show=true, truncate_output=true)
Manipulate a copy of the global_timer
, to remove some things to reduce the clutter when it is printed.
By default the resulting TimerOutput
is displayed in the terminal. Pass show_output=true
to display the resulting TimerOutput
in the terminal.
By default, the output is truncated, removing deeply nested timers and timers with very little time. To include all timers, pass truncate_output=false
. The threshold for dropping timers is if their time is less than threshold
times the total time.
By default, returns a string showing the contents of the TimerOutput
. When show_output=true
is passed, just returns the empty string.
moment_kinetics.timer_utils.reset_mk_timers!
— Methodreset_mk_timers!()
Reset all global state of timers.
moment_kinetics.timer_utils.timeit_debug_enabled
— Methodtimeit_debug_enabled()
@timeit_debug
uses a function defined in the enclosing module called timeit_debug_enabled()
to decide whether to include debug timers (included if this function returns true
, or not - with zero overhead - if it returns false
).
To control the debug timers in moment_kinetics
we define this function once, in timer_utils
, and import it from there into any other modules that use @timeit_debug.
To activate debug timers, edit this function so that it returns true
.