/* Diagnostic-only scopes for one standalone worker. Never linked in production. */ #ifndef SOLVER_PROFILE_H #define SOLVER_PROFILE_H enum { P_TOTAL, P_INTEGRATION, P_CVODE, P_RHS, P_RESIDUAL, P_JACOBIAN, P_JACOBIAN_PROBE, P_LSETUP, P_LU, P_LSOLVE, P_NEWTON, P_EVENT, P_PROPERTY, P_SAMPLING, P_APPEND, P_FLUSH, P_REPLAY, P_ENCODING, P_POLL, P_COUNT }; enum { C_STEPS, C_RHS, C_LINEAR_RHS, C_JACOBIANS, C_SETUPS, C_ERROR_FAILS, C_NEWTON_ITERS, C_NEWTON_FAILS, C_STEP_SOLVE_FAILS, C_SEGMENTS, C_JAC_REUSES, C_JAC_REFRESHES, C_SETUP_FAILURES, C_LU_FAILURES, C_SOLVE_FAILURES, C_FRICTION_EVALS, C_BOUNDARIES, C_COUNT }; typedef struct ProfileScope { double start, children; int id, active; struct ProfileScope *parent; } ProfileScope; ProfileScope profile_begin(int id); void profile_link(ProfileScope *scope); void profile_end(ProfileScope *scope); void profile_add(int id, int status, long int value); void profile_dump(void); #define PROFILE_SCOPE(id) ProfileScope profile_scope __attribute__((cleanup(profile_end)))=profile_begin(id); profile_link(&profile_scope) #endif