dolfinx.common

General tools for timing and configuration.

Functions

list_timings(comm, timing_types[, reduction])

Print out a summary of all Timer measurements, with a choice of wall time, system time or user time.

timed(task)

Decorator for timing functions.

timing(task)

Classes

Timer([name])

A timer can be used for timing tasks. The basic usage is::.

class dolfinx.common.IndexMap(*args, **kwargs)

Bases: pybind11_object

Overloaded function.

  1. __init__(self: dolfinx.cpp.common.IndexMap, comm: MPICommWrapper, local_size: int) -> None

  2. __init__(self: dolfinx.cpp.common.IndexMap, comm: MPICommWrapper, local_size: int, ghosts: numpy.ndarray[numpy.int64], ghost_owners: numpy.ndarray[numpy.int32]) -> None

  3. __init__(self: dolfinx.cpp.common.IndexMap, comm: MPICommWrapper, local_size: int, dest_src: Annotated[List[numpy.ndarray[numpy.int32]], FixedSize(2)], ghosts: numpy.ndarray[numpy.int64], ghost_owners: numpy.ndarray[numpy.int32]) -> None

property comm
create_submap(self: dolfinx.cpp.common.IndexMap, entities: numpy.ndarray[numpy.int32]) Tuple[dolfinx.cpp.common.IndexMap, numpy.ndarray[numpy.int32]]
property ghosts

Return list of ghost indices

property imbalance

Imbalance of the current IndexMap.

property index_to_dest_ranks
property local_range

Range of indices owned by this map

local_to_global(self: dolfinx.cpp.common.IndexMap, local: numpy.ndarray[numpy.int32]) numpy.ndarray[numpy.int64]
property num_ghosts
property owners
property size_global
property size_local
class dolfinx.common.Timer(name: Optional[str] = None)[source]

Bases: object

A timer can be used for timing tasks. The basic usage is:

with Timer("Some costly operation"):
    costly_call_1()
    costly_call_2()

or:

with Timer() as t:
    costly_call_1()
    costly_call_2()
    print("Elapsed time so far: %s" % t.elapsed()[0])

The timer is started when entering context manager and timing ends when exiting it. It is also possible to start and stop a timer explicitly by:

t = Timer("Some costly operation")
t.start()
costly_call()
t.stop()

and retrieve timing data using:

t.elapsed()

Timings are stored globally (if task name is given) and may be printed using functions timing, timings, list_timings, dump_timings_to_xml, e.g.:

list_timings(comm, [TimingType.wall, TimingType.user])
elapsed()[source]
resume()[source]
start()[source]
stop()[source]
dolfinx.common.timed(task: str)[source]

Decorator for timing functions.