IOUsage#

class caput.util.profiler.IOUsage(logger: logging.Logger | None = None)[source]#

A context manager that gives the amount of IO done.

To access the IO usage the context manager object must be created and bound to a variable before the with statement.

>>> u = IOUsage()
>>> with u:
...     print("do some IO in here")
do some IO in here
>>> print(u.usage)
{...}
Parameters:
loggerlogging.Logger | None

If this is not None, the values of the IO done counters will be logged at INFO level.

property usage: dict[source]#

The IO usage within the block.