PAOFLOW.transport.utils.timing#

Attributes#

Classes#

Clock

A high-resolution timing utility for measuring execution durations.

TimingManager

A timing manager that tracks multiple named clocks.

Functions#

timed_function([name])

Decorator to automatically time a function using global_timing.

Module Contents#

PAOFLOW.transport.utils.timing.comm[source]#
PAOFLOW.transport.utils.timing.rank[source]#
class PAOFLOW.transport.utils.timing.Clock(name)[source]#

A high-resolution timing utility for measuring execution durations.

Parameters:

name (str) – Descriptive name of the timed routine or block.

Variables:
  • name (str) – Name of the routine being timed.

  • call_count (int) – Number of times the timer was started and stopped.

  • total_time (float) – Total time accumulated over all calls in seconds.

  • _start_time (float or None) – Internal timestamp when the timer was last started.

Notes

Uses perf_counter for high-precision timing.

name[source]#
call_count = 0[source]#
total_time = 0.0[source]#
start()[source]#

Start the timer. Raises an error if already started.

stop()[source]#

Stop the timer and update total accumulated time. Raises an error if the timer was never started.

avg_time()[source]#
Returns:

Average time per call in seconds. Returns 0.0 if never called.

Return type:

float

time_upto_now()[source]#
Returns:

Time since last start (not included in total_time yet). Returns 0.0 if timer is not running.

Return type:

float

class PAOFLOW.transport.utils.timing.TimingManager[source]#

A timing manager that tracks multiple named clocks.

Variables:

clocks (OrderedDict) – Dictionary of active clocks indexed by name.

Notes

Only rank 0 outputs timing reports to avoid duplicate MPI prints.

clocks[source]#
start(name)[source]#

Start a named timer.

Parameters:

name (str) – Identifier for the routine being timed.

stop(name)[source]#

Stop a named timer.

Parameters:

name (str) – Identifier for the routine being timed.

Raises:

ValueError – If the clock was never started.

report(header='<global routines>')[source]#

Print a report of all clocked timings.

Parameters:

header (str) – Optional header for the printed report.

timing_upto_now(name, label=None)[source]#

Print time elapsed since a given clock was started (not yet stopped).

Parameters:
  • name (str) – Clock name to inspect.

  • label (str, optional) – Custom label to print. Defaults to clock name.

Notes

This does not stop the clock; it’s purely diagnostic.

PAOFLOW.transport.utils.timing.global_timing[source]#
PAOFLOW.transport.utils.timing.timed_function(name=None)[source]#

Decorator to automatically time a function using global_timing.

Parameters:

name (str, optional) – Custom name for the timer. If None, the function’s __name__ is used.