:mod:`pytimings.timer` ====================== .. py:module:: pytimings.timer .. autoapi-nested-parse:: Main module. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: pytimings.timer.TimingData pytimings.timer.Timings Functions ~~~~~~~~~ .. autoapisummary:: :nosignatures: pytimings.timer._default_timer_dict_entry pytimings.timer.scoped_timing pytimings.timer.cummulative_scoped_timing pytimings.timer.function_timer Attributes ~~~~~~~~~~ .. autoapisummary:: pytimings.timer.PERF_COUNTER_FUNCTION pytimings.timer.THREAD_TIME pytimings.timer.WALL_TIME pytimings.timer.SYS_TIME pytimings.timer.USER_TIME pytimings.timer.TimingDelta pytimings.timer.global_timings .. py:data:: PERF_COUNTER_FUNCTION .. py:data:: THREAD_TIME :value: 'thread' .. py:data:: WALL_TIME :value: 'wall' .. py:data:: SYS_TIME :value: 'sys' .. py:data:: USER_TIME :value: 'user' .. py:data:: TimingDelta .. py:exception:: NoTimerError(section, timings=None, is_unstopped=False) Bases: :py:obj:`Exception` Common base class for all non-exit exceptions. .. py:attribute:: section .. py:attribute:: timings .. py:attribute:: is_unstopped :value: False .. py:class:: TimingData(name) .. py:attribute:: name .. py:attribute:: _end_resources :value: None .. py:attribute:: _end_times :value: None .. py:attribute:: _process .. py:attribute:: _start_times .. py:method:: _get() .. py:method:: stop() .. py:method:: delta() .. py:function:: _default_timer_dict_entry() .. py:class:: Timings .. py:attribute:: _commited_deltas :type: dict[str, TimingDelta] .. py:attribute:: _known_timers_map :type: dict[str, tuple[bool, TimingData | None]] .. py:attribute:: extra_data .. py:method:: start(section_name: str) -> None set this to begin a named section .. py:method:: stop(section_name: str | None = None) -> int stop named section's counter or all of them if section_name is None .. py:method:: reset(section_name: str | None = None) -> None set elapsed time back to 0 for a given section or all of them if section_name is None .. py:method:: walltime(section_name: str) -> int get runtime of section in milliseconds .. py:method:: add_walltime(section_name: str, time: int) -> None .. py:method:: delta(section_name: str) -> dict[str, int] get the full delta dict .. py:method:: output_files(output_dir: pathlib.Path, csv_base: str) -> pathlib.Path output all recorded measures to a csv file .. py:method:: output_console() outputs walltime only w/o MPI-rank averaging .. py:method:: output_all_measures(out=None) -> None output all recorded measures Outputs average, min, max over all MPI processes associated to mpi_comm .. py:method:: add_extra_data(data: [dict]) Use this for something configuration data that makes the csv more informative. Data is not displayed with console output. .. py:data:: global_timings .. py:function:: scoped_timing(section_name, log_function=None, timings=None, format='') Start timer on entering block scope, stop it (and optionally output) on exiting. The printout will only show walltime for the current scope. See :py:func:`pytimings.timer.cummulative_scoped_timing` for a version with cummulative output. .. py:function:: cummulative_scoped_timing(section_name, log_function=None, timings=None, format='') Start timer on entering block scope, stop it (and optionally output) on exiting. The printout will show the cummulated walltime for all scopes with this section name. See :py:func:`pytimings.timer.scoped_timing` for a version with non-cummulative output. .. py:function:: function_timer(section_name=None, log_function=None, timings=None)