dolfinx.common

General tools for timing and configuration

Functions

list_timings(mpi_comm, timing_types)

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.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("Ellapsed 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.start()
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([TimingType.wall, TimingType.user])
elapsed()[source]
resume()[source]
start()[source]
stop()[source]
class dolfinx.common.TimingType(self: dolfinx.cpp.common.TimingType, value: int) None

Bases: pybind11_builtins.pybind11_object

Members:

wall

system

user

property name
system = <TimingType.system: 2>
user = <TimingType.user: 1>
property value
wall = <TimingType.wall: 0>
dolfinx.common.list_timings(mpi_comm, timing_types: list)[source]
dolfinx.common.timed(task: str)[source]

Decorator for timing functions.

dolfinx.common.timing(task: str)[source]