newton.utils.EventTracer#

class newton.utils.EventTracer(enabled)[source]#

Bases: object

Calculates elapsed times of functions annotated with event_scope.

Note

This class has been copied from: google-deepmind/mujoco_warp Then modified to change _STACK from being a global.

Example

@event_trace
def my_warp_function(...):
  ...

with EventTracer() as tracer:
  my_warp_function(...)
  print(tracer.trace())
__init__(enabled=True)#
Parameters:

enabled (bool) – If True, elapsed times of annotated functions are measured.

add_trace(stack, new_stack)#

Sums elapsed times from two difference traces.

trace()#

Calculates elapsed times for every node of the trace.