Performance Measuring Sample
The Performance Measuring Sample demonstrates the Performance Utility in action, using a 3D scene populated with a customizable number of spheres, and optional collision.Sample Overview
This sample is a 3D scene rendered with the help of code from the 3D Primitives sample, and instrumented with the GameDebugTools code available in the Performance Utility. The scene is composed of a number of 3D spheres that bounce around the world and optionally collide with one another. The TimeRuler and FpsCounter classes from the Performance Utility are demonstrated as part of this sample.
How the Sample Works
The PerformanceMeasuringGame class is instrumented with the GameDebugTools code available in the Performance Utility – specifically the TimeRuler and FpsCounter classes.
The Game.Draw and Game.Update calls are bracketed by calls to TimeRuler.BeginMark and .EndMark, so these calls will show up in the ruler graphic at the bottom of the screen.
The Sphere class, which holds a SpherePrimitive object borrowed from the Primitives 3D sample, draws and updates itself. Instances of this class make up the static spheres array inside the PerformanceMeasuringGame. The main game class handles creating the spheres, and collision between spheres (if enabled) as well as the world.