This directory contains examples for profiling with valgrind+callgrind and kcachegrind.
Install valgrind
, kcachegrind
, and graphviz
. For example on Ubuntu:
sudo apt-get install valgrind kcachegrind graphviz
Compile examples as release with debug info. For example:
bazel build --compilation_mode=opt --copt=-g //geometry/profiling:contact_surface_rigid_bowl_soft_ball
Run valgrind
with callgrind
to get profiling data in the file
callgrind.out.*
. For example:
valgrind --tool=callgrind bazel-bin/geometry/profiling/contact_surface_rigid_bowl_soft_ball
Run kcachegrind
to analyze profiling data. For example:
kcachegrind callgrind.out.19482
Compute contact surface between an anchored rigid bowl and a moving soft ball. The rigid bowl is a realistic non-convex object, and the soft ball uses a coarse tetrahedral mesh, which is typical in hydroelastic contact model.
To visualize the contact surface and pressure, run drake_visualizer and configure Hydroelastic Contact Visualization plugin as follows:
- From the top menu, click on: Plugins > Contacts > Configure Hydroelastic Contact Visualization.
- Change "Maximum pressure" to a reasonably large number (for example, 4e7).
- Check or uncheck "Render contact surface with pressure" as you prefer.
- Check or uncheck "Render contact surface wireframe" as you prefer.
- Click "OK".
- Run this profiling example.
Instead of the default rigid bowl, it can optionally use a rigid ball, a rigid box, or a rigid cylinder. Instead of the default soft ball, it can use a soft box or a soft cylinder.
- default rigid bowl and default soft ball,
bazel-bin/geometry/profiling/contact_surface_rigid_bowl_soft_ball
- default rigid bowl with a soft box option,
bazel-bin/geometry/profiling/contact_surface_rigid_bowl_soft_ball --soft=box
- rigid box option and default soft ball,
bazel-bin/geometry/profiling/contact_surface_rigid_bowl_soft_ball --rigid=box
- general syntax with all options.
bazel-bin/geometry/profiling/contact_surface_rigid_bowl_soft_ball \
--rigid=[ball, bowl, box, cylinder] --soft=[ball, box, cylinder]