pytimings.timer

Main module.

Module Contents

Classes

TimingData

Timings

Functions

_default_timer_dict_entry()

scoped_timing(section_name[, log_function, timings, ...])

Start timer on entering block scope, stop it (and optionally output) on exiting.

cummulative_scoped_timing(section_name[, ...])

Start timer on entering block scope, stop it (and optionally output) on exiting.

function_timer([section_name, log_function, timings])

Attributes

PERF_COUNTER_FUNCTION

THREAD_TIME

WALL_TIME

SYS_TIME

USER_TIME

TimingDelta

global_timings

pytimings.timer.PERF_COUNTER_FUNCTION[source]
pytimings.timer.THREAD_TIME = 'thread'[source]
pytimings.timer.WALL_TIME = 'wall'[source]
pytimings.timer.SYS_TIME = 'sys'[source]
pytimings.timer.USER_TIME = 'user'[source]
pytimings.timer.TimingDelta[source]
exception pytimings.timer.NoTimerError(section, timings=None, is_unstopped=False)[source]

Bases: Exception

Common base class for all non-exit exceptions.

section[source]
timings[source]
is_unstopped = False[source]
class pytimings.timer.TimingData(name)[source]
name[source]
_end_resources = None[source]
_end_times = None[source]
_process[source]
_start_times[source]
_get()[source]
stop()[source]
delta()[source]
pytimings.timer._default_timer_dict_entry()[source]
class pytimings.timer.Timings[source]
_commited_deltas: dict[str, TimingDelta][source]
_known_timers_map: dict[str, tuple[bool, TimingData | None]][source]
extra_data[source]
start(section_name: str) None[source]

set this to begin a named section

stop(section_name: str | None = None) int[source]

stop named section’s counter or all of them if section_name is None

reset(section_name: str | None = None) None[source]

set elapsed time back to 0 for a given section or all of them if section_name is None

walltime(section_name: str) int[source]

get runtime of section in milliseconds

add_walltime(section_name: str, time: int) None[source]
delta(section_name: str) dict[str, int][source]

get the full delta dict

output_files(output_dir: pathlib.Path, csv_base: str) pathlib.Path[source]

output all recorded measures to a csv file

output_console()[source]

outputs walltime only w/o MPI-rank averaging

output_all_measures(out=None) None[source]

output all recorded measures

Outputs average, min, max over all MPI processes associated to mpi_comm

add_extra_data(data: [dict])[source]

Use this for something configuration data that makes the csv more informative.

Data is not displayed with console output.

pytimings.timer.global_timings[source]
pytimings.timer.scoped_timing(section_name, log_function=None, timings=None, format='')[source]

Start timer on entering block scope, stop it (and optionally output) on exiting.

The printout will only show walltime for the current scope. See pytimings.timer.cummulative_scoped_timing() for a version with cummulative output.

pytimings.timer.cummulative_scoped_timing(section_name, log_function=None, timings=None, format='')[source]

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 pytimings.timer.scoped_timing() for a version with non-cummulative output.

pytimings.timer.function_timer(section_name=None, log_function=None, timings=None)[source]