VR-Link API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Performance Measuring Example

Table of Contents

Performance Measuring

VR-Link provides some classes to facilitate performace profiling of sections of code. This functionality was added to VR-Link 3.12 for internal use, but may be used by customers. The provided classes use OS-dependent high performance counters to record the number of processor cycles between start() and stop() calls. The output is provided in seconds.

Implementation

The performance statistics features are implemented in the following classes:

Example Code

Here is an example of how the performance statistics classes can be used. This example contains two code sections, however there is no limit to the number of sections which can be created.

// Defines the classes DtPerformanceStats, DtTimeStatistic, and DtTimedSection
// Defines DtInfo
#include <vlutil/vlPrint.h>
void foo()
{
// A dummy function
}
void measurePerformance()
{
// Create names (via enumerations) for each section of code you want
// to measure.
enum Stats { LoopTimeStat,FooTimeStat };
// Create a DtTimedSection to measure, this could be
// an initialization routine, or some computation
DtTimedSection sectionOne;
sectionOne.start();
// here is some code that you want to measure....
for (int i = 0; i < 100; ++i)
{
DtInfo << "some processing: " << i+10/34 << std::endl;
}
sectionOne.stop();
// Store the time for this section. You can measure this type of section
// repeatedly, storing it each time.
reporter.addTime(LoopTimeStat,sectionOne.duration());
// Create a new section to measure the time taken to call foo().
DtTimedSection sectionTwo;
sectionTwo.start();
foo();
sectionTwo.stop();
reporter.addTime(FooTimeStat,sectionTwo.duration());
// Output the average render time.
double aveTimeFoo = reporter.avg(FooTimeStat);
DtInfo << "Iteration takes " << aveTimeFoo << std::endl;
// Or, we could be outputting to a graphics package.
//myGraph->addDataPoint(GetCurrentTime(),aveTimeFoo);
}

Document ID: Generated on Thu Sep 19 02:12:35 EDT 2024 from SVN revision 269601
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)