|
AGX Dynamics
2.35.0.1
|
Base statistics gathering class. More...
#include <Statistics.h>
Inheritance diagram for agx::Statistics:Classes | |
| class | Data |
| Statistics data storage class. More... | |
Public Member Functions | |
| Statistics () | |
| AbstractData (const char *name, const agxData::Format *format) | |
| String | accumulatedToString () const |
| Reference-less. More... | |
| void | accumulatedToString (String &result) const |
| Converts the accumulated value to a human readable string using the "ascii" format for the type of the value. More... | |
| void | addChild (ProviderHandle *child) |
| Add the given ProviderHandle to the list of children, and set the parent pointer of the child to the new parent. More... | |
| template<typename T > | |
| Data< T > * | asTypedData () |
| Converts this abstract representation to a type specified data handle. More... | |
| void | clear () |
| Reset all statistics values, setting both the current and accumulated value using the type's default constructor. More... | |
| virtual void | clear (bool clearAccumulated=true)=0 |
| Sets the current and accumulated values to zero, or the equivalent for complex types. More... | |
| void | clear (bool recursive=false, bool clearAccumulated=true) |
| Clears the data help by this ProviderHandle, using the type's default constructor. More... | |
| void | clearCurrent () |
| Reset all statistics values, setting the current value using the type's default constructor. More... | |
| ProviderHandle * | getChild (const char *name) |
| ProviderHandle * | getChild (size_t index) |
| const ProviderHandleRefVector & | getChildren () const |
| AbstractData * | getData (const char *name) const |
| AbstractData * | getData (const char *providerName, const char *dataName, size_t providerIndex=0) |
| Get a data handle from the statistics tree. More... | |
| AbstractData * | getData (const String &providerName, const String &dataName, size_t providerIndex=0) |
| Get a data handle from the statistics tree. More... | |
| AbstractData * | getData (void *instance, const char *name) |
| Get a data handle from a statistics handle. More... | |
| template<typename T > | |
| Data< T > * | getData (void *instance, const char *name) |
| Templated convenience method that returns the result from the non-templated 'getData(*)' with the same arguments as a typed data handle. More... | |
| AbstractData * | getData (void *instance, const Path &path) |
| Get a data handle from the statistics tree. More... | |
| const DataTable & | getDataTable () const |
| bool | getEnable () const |
| Returns true if this Statistics object is currently accepting new data. More... | |
| const agxData::Format * | getFormat () const |
| const char * | getName () |
| const char * | getName () const |
| size_t | getNumChildren () const |
| void * | getOwner () |
| template<typename T > | |
| T * | getOwner () |
| Convenience method that test if the owner was of a specific type and if so returns a pointer to the owner cast to that type. More... | |
| const void * | getOwner () const |
| template<typename T > | |
| const T * | getOwner () const |
| ProviderHandle * | getParent () |
| ProviderHandle * | getProviderHandle (void *instance) |
| Returns the provider handle for the given statistics provider. More... | |
| const ProviderHandleRefVector & | getProviderHandles (const char *name) |
| Returns handles to all providers that have been registered with the given name. More... | |
| ProviderHandle * | getRootProviderHandle () |
| Returns a handle to the root of the statistics tree. More... | |
| TimingInfo | getTimingInfo (const String &providerName, const String &dataName, size_t providerIndex=0) |
| Will find a provider by name, and data by name, and return the stored statistics data. More... | |
| String | getTimingString (const String &providerName, const String &dataName, size_t providerIndex=0) |
| Helper for C# swig binding. More... | |
| bool | isEnabled () const |
| Returns true if this Statistics object is currently accepting new data. More... | |
| bool | isImplicit () const |
| Returns true if this ProviderHandle was implicitly created. More... | |
| bool | isRoot () const |
| Returns true if this node has a nullptr parent. More... | |
| bool | isTaskNode () const |
| Returns true if this ProviderHandle was created as a handle for a Task. More... | |
| bool | isTiming () const |
| void | print (std::ostream &stream, bool includeTaskTimers, unsigned depth=0) |
| Recursively print the data in this ProviderHandle and all its children. More... | |
| void | print (std::ostream &stream, bool includeTaskTimers=false) |
| Print print statistics in a human-readable form to the given stream. More... | |
| String | printed (bool includeTaskTimers=false) |
| Print print statistics in a human-readable form to the given stream. More... | |
| ProviderHandle (void *owner, Statistics *statistics) | |
| bool | registerDataProvider (void *provider, const char *name, void *context=(void *) nullptr) |
| Register a new data provider. More... | |
| bool | registerDataProvider (void *provider, const String &name, void *context=(void *) nullptr) |
| Convenience method, calls the const char* version of registerDataProvider(*). More... | |
| TaskTimingReportHandle * | registerTaskTimerProvider (void *provider, const char *name, void *context) |
| Used by the tasks to create a provider handle designed for task timer reporting. More... | |
| template<typename T > | |
| AbstractData * | report (void *instance, const char *name, const T &value) |
| Report statistics. More... | |
| template<typename T > | |
| AbstractData * | reportAdditionalTiming (void *instance, const char *name, const T &timing) |
| Increments the chosen timing value instead of setting it. More... | |
| AbstractData * | reportAdditionalTiming (void *instance, const char *name, const Timer &timer) |
| Convenience method that reads the current value from a timer. More... | |
| template<typename T > | |
| AbstractData * | reportTiming (void *instance, const char *name, const T &timing) |
| Report a timing statistics. More... | |
| AbstractData * | reportTiming (void *instance, const char *name, const Timer &timer) |
| Convenience report method that reads the current time from a timer. More... | |
| void | setContext (void *instance, void *context) |
| Move a sub-tree to a new location. More... | |
| void | setEnable (bool) |
| Enables or disables gathering of statistics data. More... | |
| void | setIsTiming (bool isTiming=true) |
| void | setName (const char *name) |
| Set the name of the provider. More... | |
| String | toString () const |
| Reference-less method to be used with Lua scripts. More... | |
| void | toString (String &result) const |
| Converts the current value to a human readable string using the "ascii" format for the type of the value. More... | |
| virtual agxData::Value * | toValue () const =0 |
| bool | unregisterDataProvider (void *provider) |
| Removes the provider handle for the given provider from the statistics tree. More... | |
Public Member Functions inherited from agx::Singleton | |
| Singleton (int priority=DEFAULT_PRIORITY) | |
| Default constructor. More... | |
| virtual std::string | getClassName () const =0 |
| int | getPriority () const |
| Return the shutdown priority of the singleton instance. More... | |
| virtual void | shutdown () |
| Implement this method to cleanup your Singleton class. More... | |
Static Public Member Functions | |
| static bool | hasInstance () |
| static Statistics * | instance () |
Protected Types | |
| enum | FlagFields { IS_TASK_NODE = 0x1 , SUBTREE_IS_EMPTY = 0x2 } |
Protected Member Functions | |
| virtual | ~AbstractData () |
| virtual | ~ProviderHandle () |
| virtual | ~Statistics () |
| virtual const void * | accumulatedPtr () const =0 |
| Returns a raw pointer to the memory location where the current value is stored. More... | |
| void | adoptChild (ProviderHandle *child) |
| Move a ProviderHandle from its current parent into 'this'. More... | |
| void | createRootNode () |
| void | decayBranch (ProviderHandle *leaf) |
| Remove implicit childless nodes up a branch. More... | |
| template<typename T > | |
| Data< T > * | getOrCreateData (const char *name) |
| Makes sure that a data handle with the given names exists. More... | |
| virtual bool | isTaskTimer (AbstractData *data) |
| Tests if the given data handle corresponds to one of the special task timing values. More... | |
| void | setIsTaskNode (bool isTaskNode) |
| Returns true if the ProviderHandle contains task timing values. More... | |
| void | takeChildren (ProviderHandle *currentParent) |
| Move all children from the given ProviderHandle into 'this'. More... | |
| bool | updateEmptyFlags () |
| Recursively updates the SUBTREE_IS_EMPTY flags. More... | |
| virtual const void * | valuePtr () const =0 |
| Returns a raw pointer to the memory location where the current value is stored. More... | |
Protected Member Functions inherited from agx::Singleton | |
| virtual | ~Singleton () |
| Destructor. More... | |
| void | _shutdown () |
Static Protected Member Functions | |
| static const char * | copyString (const char *) |
| All strings held inside the statistics tree is owned by the statistics tree. More... | |
Protected Attributes | |
| ProviderHandleRefVector | m_children |
| DataTable | m_dataTable |
| Int32 | m_flags |
| const char * | m_name |
| void * | m_owner |
| ProviderHandle * | m_parent |
| Statistics * | m_statistics |
Base statistics gathering class.
An abstract handle for a statistics value.
Internal representation of the data providers.
It is a Singleton and the default instance can be accessed using 'Statistics::instance()'. Any object can report data to an instance of this class and all tasks will report their profiling timer values to the default Statistics object.
Data is stored hierarchically, so each provider must register themselves with a context. The context is what defines the parent node in the statistics tree.
Keeps a list of child ProviderHandles and a list of data reported by the reporter for the ProviderHandle.
Actual data storage is managed by templated subclasses.
Definition at line 98 of file Statistics.h.
| typedef agx::observer_ptr< const AbstractData > agx::Statistics::AbstractDataConstObserver |
Definition at line 103 of file Statistics.h.
| typedef agx::ref_ptr< const AbstractData > agx::Statistics::AbstractDataConstRef |
Definition at line 103 of file Statistics.h.
Definition at line 103 of file Statistics.h.
Definition at line 103 of file Statistics.h.
| typedef HashTable<const char*, AbstractDataRef> agx::Statistics::DataTable |
Definition at line 107 of file Statistics.h.
| typedef agx::observer_ptr< const ProviderHandle > agx::Statistics::ProviderHandleConstObserver |
Definition at line 101 of file Statistics.h.
| typedef agx::ref_ptr< const ProviderHandle > agx::Statistics::ProviderHandleConstRef |
Definition at line 101 of file Statistics.h.
Definition at line 101 of file Statistics.h.
Definition at line 102 of file Statistics.h.
Definition at line 102 of file Statistics.h.
Definition at line 101 of file Statistics.h.
Definition at line 102 of file Statistics.h.
|
protected |
| Enumerator | |
|---|---|
| IS_TASK_NODE | |
| SUBTREE_IS_EMPTY | |
Definition at line 550 of file Statistics.h.
| agx::Statistics::Statistics | ( | ) |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
| agx::Statistics::AbstractData | ( | const char * | name, |
| const agxData::Format * | format | ||
| ) |
|
protectedpure virtual |
Returns a raw pointer to the memory location where the current value is stored.
Use with caution.
| String agx::Statistics::accumulatedToString | ( | ) | const |
Reference-less.
Converts the accumulated value to a human readable string using the "ascii" format for the type of the value.
| void agx::Statistics::accumulatedToString | ( | String & | result | ) | const |
Converts the accumulated value to a human readable string using the "ascii" format for the type of the value.
| void agx::Statistics::addChild | ( | ProviderHandle * | child | ) |
Add the given ProviderHandle to the list of children, and set the parent pointer of the child to the new parent.
Will fail if the child already has a parent. See 'adoptChild(*)'.
|
protected |
Move a ProviderHandle from its current parent into 'this'.
| Data<T>* agx::Statistics::asTypedData | ( | ) |
Converts this abstract representation to a type specified data handle.
Will return true if the given type is wrong.
| void agx::Statistics::clear | ( | ) |
Reset all statistics values, setting both the current and accumulated value using the type's default constructor.
|
pure virtual |
Sets the current and accumulated values to zero, or the equivalent for complex types.
Uses default constructor.
| void agx::Statistics::clear | ( | bool | recursive = false, |
| bool | clearAccumulated = true |
||
| ) |
Clears the data help by this ProviderHandle, using the type's default constructor.
| recursive | If true, then the same operations will be performed on the children as well. |
| clearAccumulated | If true, then the accumulated values are cleared as well. |
| void agx::Statistics::clearCurrent | ( | ) |
Reset all statistics values, setting the current value using the type's default constructor.
|
staticprotected |
All strings held inside the statistics tree is owned by the statistics tree.
This method is used to make a copy of incoming strings so we know how and when to delete them.
|
protected |
|
protected |
Remove implicit childless nodes up a branch.
| ProviderHandle* agx::Statistics::getChild | ( | const char * | name | ) |
| ProviderHandle* agx::Statistics::getChild | ( | size_t | index | ) |
| const ProviderHandleRefVector& agx::Statistics::getChildren | ( | ) | const |
| AbstractData* agx::Statistics::getData | ( | const char * | name | ) | const |
| name | The name of a data element reported to this ProviderHandle. |
| AbstractData* agx::Statistics::getData | ( | const char * | providerName, |
| const char * | dataName, | ||
| size_t | providerIndex = 0 |
||
| ) |
Get a data handle from the statistics tree.
Since there may be many providers with the same name, a index is used to identify a particular provider.
| providerName | The name of a data provider that reported the data sample we should get. |
| dataName | The name of the data sample to get. |
| providerIndex | Index into the list of providers with the given name. |
| AbstractData* agx::Statistics::getData | ( | const String & | providerName, |
| const String & | dataName, | ||
| size_t | providerIndex = 0 |
||
| ) |
Get a data handle from the statistics tree.
Convenience method using strings instead of pointers.
| providerName | The name of a data provider that reported the data sample we should get. |
| dataName | The name of the data sample to get. |
| providerIndex | Index into the list of providers with the given name. |
| AbstractData* agx::Statistics::getData | ( | void * | instance, |
| const char * | name | ||
| ) |
Get a data handle from a statistics handle.
| instance | Identifier for the data provider. |
| name | The name of the data to fetch. |
| Data<T>* agx::Statistics::getData | ( | void * | instance, |
| const char * | name | ||
| ) |
Templated convenience method that returns the result from the non-templated 'getData(*)' with the same arguments as a typed data handle.
| AbstractData* agx::Statistics::getData | ( | void * | instance, |
| const Path & | path | ||
| ) |
Get a data handle from the statistics tree.
The tree is traversed from the provider identified by the 'instance' along the given path. If there are ambiguous steps in the path, i.e., multiple children with the same name, then the first match in each such case will be used.
| instance | Identifier for the statistics node where the path traversal starts. |
| path | Path from the statistics node for the given identifier to the wanted statistics element. |
| const DataTable& agx::Statistics::getDataTable | ( | ) | const |
| bool agx::Statistics::getEnable | ( | ) | const |
Returns true if this Statistics object is currently accepting new data.
| const agxData::Format* agx::Statistics::getFormat | ( | ) | const |
| const char* agx::Statistics::getName | ( | ) |
| const char* agx::Statistics::getName | ( | ) | const |
| size_t agx::Statistics::getNumChildren | ( | ) | const |
|
protected |
Makes sure that a data handle with the given names exists.
| void* agx::Statistics::getOwner | ( | ) |
| T* agx::Statistics::getOwner | ( | ) |
Convenience method that test if the owner was of a specific type and if so returns a pointer to the owner cast to that type.
| const void* agx::Statistics::getOwner | ( | ) | const |
| const T* agx::Statistics::getOwner | ( | ) | const |
| ProviderHandle* agx::Statistics::getParent | ( | ) |
| ProviderHandle* agx::Statistics::getProviderHandle | ( | void * | instance | ) |
Returns the provider handle for the given statistics provider.
| const ProviderHandleRefVector& agx::Statistics::getProviderHandles | ( | const char * | name | ) |
Returns handles to all providers that have been registered with the given name.
| ProviderHandle* agx::Statistics::getRootProviderHandle | ( | ) |
Returns a handle to the root of the statistics tree.
| TimingInfo agx::Statistics::getTimingInfo | ( | const String & | providerName, |
| const String & | dataName, | ||
| size_t | providerIndex = 0 |
||
| ) |
Will find a provider by name, and data by name, and return the stored statistics data.
Returns -1,-1 on fail.
| String agx::Statistics::getTimingString | ( | const String & | providerName, |
| const String & | dataName, | ||
| size_t | providerIndex = 0 |
||
| ) |
Helper for C# swig binding.
Will find a provider by name, and data by name, and return a string with timing info, or an empty string on fail.
|
static |
|
static |
| bool agx::Statistics::isEnabled | ( | ) | const |
Returns true if this Statistics object is currently accepting new data.
| bool agx::Statistics::isImplicit | ( | ) | const |
Returns true if this ProviderHandle was implicitly created.
When a providers registers itself with a context but the context have not yet been registered, then an implicit ProviderHandle is created for the context.
| bool agx::Statistics::isRoot | ( | ) | const |
Returns true if this node has a nullptr parent.
| bool agx::Statistics::isTaskNode | ( | ) | const |
Returns true if this ProviderHandle was created as a handle for a Task.
|
protectedvirtual |
Tests if the given data handle corresponds to one of the special task timing values.
| bool agx::Statistics::isTiming | ( | ) | const |
| void agx::Statistics::print | ( | std::ostream & | stream, |
| bool | includeTaskTimers, | ||
| unsigned | depth = 0 |
||
| ) |
Recursively print the data in this ProviderHandle and all its children.
| void agx::Statistics::print | ( | std::ostream & | stream, |
| bool | includeTaskTimers = false |
||
| ) |
Print print statistics in a human-readable form to the given stream.
If 'includeTaskTimers' is true, then the task timer values will be included as well, which may produce quite a bit of output.
| stream | The stream to print to. |
| includeTaskTimers | If true, then the output will include profiling information for every executed task. |
| String agx::Statistics::printed | ( | bool | includeTaskTimers = false | ) |
Print print statistics in a human-readable form to the given stream.
If 'includeTaskTimers' is true, then the task timer values will be included as well, which may produce quite a bit of output.
| includeTaskTimers | If true, then the output will include profiling information for every executed task. |
| agx::Statistics::ProviderHandle | ( | void * | owner, |
| Statistics * | statistics | ||
| ) |
| owner | A unique identifier for the new ProviderHandle. |
| statistics | The statistics object that is responsible for the new ProviderHandle. |
| bool agx::Statistics::registerDataProvider | ( | void * | provider, |
| const char * | name, | ||
| void * | context = (void *) nullptr |
||
| ) |
Register a new data provider.
This must be done before any data can be reported from that provider.
The 'context' parameter defines the location of the new provider handle node in the statistics tree. It be the same value as the 'provider' argument for another call to 'registerDataProvider(*)', past or future. It may also be nullptr, which will place the new provider handle node below the root of the tree.
| provider | A unique identifier for the new provider. Often the 'this' pointer in the calling code. |
| name | A name for the new provider. |
| context | Provider for the parent node in the statistics tree. May be nullptr. |
| bool agx::Statistics::registerDataProvider | ( | void * | provider, |
| const String & | name, | ||
| void * | context = (void *) nullptr |
||
| ) |
Convenience method, calls the const char* version of registerDataProvider(*).
| TaskTimingReportHandle* agx::Statistics::registerTaskTimerProvider | ( | void * | provider, |
| const char * | name, | ||
| void * | context | ||
| ) |
Used by the tasks to create a provider handle designed for task timer reporting.
| AbstractData* agx::Statistics::report | ( | void * | instance, |
| const char * | name, | ||
| const T & | value | ||
| ) |
Report statistics.
The data element named 'name' in the provider handle for the provider 'instance' will be set to 'value' and the corresponding accumulated value will be incremented.
| instance | A unique identifier for a data provider. Must have been part of a prior call to 'registerDataProvider(*) or 'registerTaskTimerProvider(*)'. |
| name | The name of the reported data element. |
| value | The value being reported. |
| AbstractData* agx::Statistics::reportAdditionalTiming | ( | void * | instance, |
| const char * | name, | ||
| const T & | timing | ||
| ) |
Increments the chosen timing value instead of setting it.
| AbstractData* agx::Statistics::reportAdditionalTiming | ( | void * | instance, |
| const char * | name, | ||
| const Timer & | timer | ||
| ) |
Convenience method that reads the current value from a timer.
| AbstractData* agx::Statistics::reportTiming | ( | void * | instance, |
| const char * | name, | ||
| const T & | timing | ||
| ) |
Report a timing statistics.
Functionally very similar to 'report(*)'.
| instance | A unique identifier for a data provider. Must have been part of a prior call to 'registerDataProvider(*) or 'registerTaskTimerProvider(*)'. |
| name | The name of the reported data element. |
| timing | The timing value being reported. |
| AbstractData* agx::Statistics::reportTiming | ( | void * | instance, |
| const char * | name, | ||
| const Timer & | timer | ||
| ) |
Convenience report method that reads the current time from a timer.
| void agx::Statistics::setContext | ( | void * | instance, |
| void * | context | ||
| ) |
Move a sub-tree to a new location.
| instance | The identifier for the statistics node that should be moved. |
| context | The identifier for the statistics node that should be the new parent. |
| void agx::Statistics::setEnable | ( | bool | ) |
Enables or disables gathering of statistics data.
|
protected |
Returns true if the ProviderHandle contains task timing values.
| void agx::Statistics::setIsTiming | ( | bool | isTiming = true | ) |
| void agx::Statistics::setName | ( | const char * | name | ) |
Set the name of the provider.
|
protected |
Move all children from the given ProviderHandle into 'this'.
| String agx::Statistics::toString | ( | ) | const |
Reference-less method to be used with Lua scripts.
| void agx::Statistics::toString | ( | String & | result | ) | const |
Converts the current value to a human readable string using the "ascii" format for the type of the value.
|
pure virtual |
| bool agx::Statistics::unregisterDataProvider | ( | void * | provider | ) |
Removes the provider handle for the given provider from the statistics tree.
Any remaining children are moved to the removed node's parent.
|
protected |
Recursively updates the SUBTREE_IS_EMPTY flags.
Returns true if subtree is empty. An ProviderHandle is considered empty if the only data recored in the subtree are task timer values.
|
protectedpure virtual |
Returns a raw pointer to the memory location where the current value is stored.
Use with caution.
|
protected |
Definition at line 545 of file Statistics.h.
|
protected |
Definition at line 546 of file Statistics.h.
|
protected |
Definition at line 547 of file Statistics.h.
|
protected |
Definition at line 542 of file Statistics.h.
|
protected |
Definition at line 541 of file Statistics.h.
|
protected |
Definition at line 543 of file Statistics.h.
|
protected |
Definition at line 544 of file Statistics.h.