A simple tracer that records a stack of traces.
Record the end of a calculation.
Examples
>>> from openfisca_core import tracers
>>> tracer = tracers.SimpleTracer()
>>> tracer.record_calculation_start("variable", 2020)
>>> tracer.record_calculation_end()
>>> tracer.stack
[]
Record the start of a calculation.
Examples
>>> from openfisca_core import tracers
>>> tracer = tracers.SimpleTracer()
>>> tracer.record_calculation_start("variable", 2020)
>>> tracer.stack
[{'name': 'variable', 'period': 2020}]
Return the stack of traces.
A node in the tracing tree.
Calculate the time spent in the node.
round – Whether to round the result.
float – The time spent in the node.
Examples
>>> from openfisca_core import tracers
>>> node = tracers.TraceNode("variable", 2020)
>>> node.start = 1.123122313
>>> node.end = 1.12312313123
>>> node.calculation_time()
8.182e-07
>>> node.calculation_time(round_=False)
8.182299999770493e-07
Calculate the time spent on the formula.
float – The time spent on the formula.
Examples
>>> from openfisca_core import tracers
>>> node = tracers.TraceNode("variable", 2020)
>>> node.start = 1.123122313 * 11
>>> node.end = 1.12312313123 * 11
>>> child = tracers.TraceNode("variable", 2020)
>>> child.start = 1.123122313
>>> child.end = 1.12312313123
>>> for i in range(10):
... node.children = [child, *node.children]
>>> node.formula_time()
8.182e-07