Statistics
Statistics contains general facilities for recording and collecting statistical data like counts and times. It is mainly used for collecting rendering statistics like the amount of time need for a frame or the number of visible polygons, but it can be used for any kind of statistics.
The statistics data is collected in the form of single OSG::StatElem structures which are bundled in an OSG::StatCollector. Every StatElem? element can have one of a number of different types, the predefined ones are
- Int (OSG::StatIntElem)
- Real32 (OSG::StatRealElem)
- Time (OSG::StatTimeElem)
- String (OSG::StatStringElem)
Every OSG::StatElement also has a description in the form of a OSG::StatElemDesc that describes the actual use of the element. The OSG::StatCollector can hold an arbitrary subset of all known elements. The OSG::StatElemDesc obj holding the element type and ID must exist as long as any collector holds a corresponding elem object. The OSG::StatElemDesc constructor creates a unique ID which can be used to create/access an correspondent Elem (which holds the value) in any collector.
The contents of the OSG::StatCollector can be accessed either for every OSG::StatElem separately or can be output as a whole in the form of a string. For displaying the contents of a StatCollector? on screen the OSG::StatisticsForground can be used. The various StatElem? objects provide methods to access or change the value (e.g get/set increase/decrease). In addition, every StatElem? holds a on-flag to activate/deactivate the statistic element.
The main idea of the Statistics structure lies in high flexibility. Thus the set of variables that are statistically relevant is not fixed, new ones can be added by the application if necessary.
Extending
To extend the Statistics you must create an instance of the OSG::StatElemDesc class. It is templated and parametrized by the OSG::StatElem that the new variable should have.
Custom Formatting Variables
In addition to the standard printf style formatting strings, the stats output support several custom values.
- r - When used on a time value, computes reciprical
- per - When used on a Rel value treats it as a percentage
- MB, KB, GB - When used on a IntOnce?, divides the value by 1024, 10242, and 10243 respectively.
