Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Google deepmind Mujoco Platform Sim Profiler

From Leeroopedia
Knowledge Sources
Domains Profiling, GUI
Last Updated 2026-02-15 04:00 GMT

Overview

Collects and displays simulation performance metrics (CPU timers and dimensionality statistics) as real-time ImGui/ImPlot charts.

Description

sim_profiler.cc implements the SimProfiler class which maintains rolling-window buffers (200 frames) of simulation performance data. It tracks CPU timing breakdowns (total, collision, prepare, solve, other) from MuJoCo's mjTIMER counters, and dimensionality statistics (DOF, body count, constraints, sqrt NNZ, contacts, iterations) from mjData. The Update method computes per-step averages by dividing timer durations by step counts, handling the case where the simulation is paused (zero step count). The Clear method resets all buffers to zero.

Usage

Used by Studio's profiler panel to display real-time simulation performance. Updated each frame with current mjModel and mjData, the profiler data is rendered as stacked area charts via ImPlot showing where compute time is spent.

Code Reference

Source Location

Key Functions

SimProfiler::SimProfiler();
void SimProfiler::Clear();
void SimProfiler::Update(const mjModel* model, const mjData* data);
// Tracks: cpu_total_, cpu_collision_, cpu_prepare_, cpu_solve_, cpu_other_
// Tracks: dim_dof_, dim_body_, dim_constraint_, dim_sqrt_nnz_, dim_contact_, dim_iteration_

Import

#include "experimental/platform/sim_profiler.h"

I/O Contract

Inputs

Name Type Required Description
model const mjModel* Yes MuJoCo model for dimensionality data
data const mjData* Yes MuJoCo data with timer and constraint statistics

Outputs

Name Type Description
CPU timers std::vector<mjtNum> Rolling buffers of per-step CPU timing (total, collision, prepare, solve, other)
Dimensionality std::vector<mjtNum> Rolling buffers of simulation dimensions (DOF, bodies, constraints, contacts, etc.)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment