CoriEngine
Loading...
Searching...
No Matches
Cori::Profiling::InstanceMetrics< T > Class Template Reference

This utility lets you count class instances in various ways. @detials You can see how much instances was created in total, how many are currently alive, how many instances of derived classes were created, and how much are currently alive. For a type to be instance counted it should derive from Trackable. More...

#include <InstanceMetrics.hpp>

Public Types

using DerivedMetricsReporter = std::function<void()>
using DerivedMetricsProvider = std::function<std::pair<int64_t, int64_t>()>

Static Public Member Functions

static int64_t GetDirectAliveCount ()
 Checks how many instances of type T is alive, not including derived classes.
static int64_t GetDirectTotalCreatedCount ()
 Checks how many instances of type T were created, not including derived classes.
static int64_t GetAliveCount ()
 Checks how many instances of type T is alive, including derived classes.
static int64_t GetTotalCreatedCount ()
 Checks how many instances of type T were created, including derived classes.
static void Report (const std::string &indent="")
 Will report the data about type T instances.
static std::vector< std::pair< std::string, int64_t > > GetAliveCountData ()
 Retries the data about alive instances of type T including derived instances.
static std::vector< std::pair< std::string, int64_t > > GetTotalCreatedCountData ()
 Retries the data about created instances of type T including derived instances.

Static Protected Member Functions

static void Increment ()
static void Decrement ()
static void RegisterDerivedMetricsProvider (const std::type_index &derivedTypeId, DerivedMetricsProvider provider)
static void RegisterDerivedReporter (const std::type_index &derivedTypeId, DerivedMetricsReporter reporter)

Friends

template<typename DerivedType, typename... BasePack>
class Trackable

Detailed Description

template<typename T>
class Cori::Profiling::InstanceMetrics< T >

This utility lets you count class instances in various ways. @detials You can see how much instances was created in total, how many are currently alive, how many instances of derived classes were created, and how much are currently alive. For a type to be instance counted it should derive from Trackable.

Definition at line 10 of file InstanceMetrics.hpp.

Member Typedef Documentation

◆ DerivedMetricsProvider

template<typename T>
using Cori::Profiling::InstanceMetrics< T >::DerivedMetricsProvider = std::function<std::pair<int64_t, int64_t>()>

Definition at line 13 of file InstanceMetrics.hpp.

◆ DerivedMetricsReporter

template<typename T>
using Cori::Profiling::InstanceMetrics< T >::DerivedMetricsReporter = std::function<void()>

Definition at line 12 of file InstanceMetrics.hpp.

Member Function Documentation

◆ Decrement()

template<typename T>
void Cori::Profiling::InstanceMetrics< T >::Decrement ( )
inlinestaticprotected

Definition at line 140 of file InstanceMetrics.hpp.

◆ GetAliveCount()

template<typename T>
int64_t Cori::Profiling::InstanceMetrics< T >::GetAliveCount ( )
inlinestatic

Checks how many instances of type T is alive, including derived classes.

Returns
Amount alive including derived classes. @detils Example usage: InstanceMetrics<T>::GetAliveCount();
Reruns amount of currently alive instances of T.

Definition at line 41 of file InstanceMetrics.hpp.

Here is the call graph for this function:

◆ GetAliveCountData()

template<typename T>
std::vector< std::pair< std::string, int64_t > > Cori::Profiling::InstanceMetrics< T >::GetAliveCountData ( )
inlinestatic

Retries the data about alive instances of type T including derived instances.

Returns
Vector with pairs of string and int64_t, string is the demangled name of the type and int64_t is currently alive instances. @detils Example usage: InstanceMetrics<T>::GetAliveCountData();
Reruns the data about alive instances of type T and its derived classes.

Definition at line 93 of file InstanceMetrics.hpp.

Here is the call graph for this function:

◆ GetDirectAliveCount()

template<typename T>
int64_t Cori::Profiling::InstanceMetrics< T >::GetDirectAliveCount ( )
inlinestatic

Checks how many instances of type T is alive, not including derived classes.

Returns
Amount alive not including derived classes. @detils Example usage: InstanceMetrics<T>::GetDirectAliveCount();
Reruns amount of currently alive instances of T.

Definition at line 21 of file InstanceMetrics.hpp.

◆ GetDirectTotalCreatedCount()

template<typename T>
int64_t Cori::Profiling::InstanceMetrics< T >::GetDirectTotalCreatedCount ( )
inlinestatic

Checks how many instances of type T were created, not including derived classes.

Returns
Amount created not including derived classes. @detils Example usage: InstanceMetrics<T>::GetDirectTotalCreatedCount();
Reruns amount of created instances of T.

Definition at line 31 of file InstanceMetrics.hpp.

◆ GetTotalCreatedCount()

template<typename T>
int64_t Cori::Profiling::InstanceMetrics< T >::GetTotalCreatedCount ( )
inlinestatic

Checks how many instances of type T were created, including derived classes.

Returns
Amount created including derived classes. @detils Example usage: InstanceMetrics<T>::GetTotalCreatedCount();
Reruns amount of created instances of T.

Definition at line 55 of file InstanceMetrics.hpp.

Here is the call graph for this function:

◆ GetTotalCreatedCountData()

template<typename T>
std::vector< std::pair< std::string, int64_t > > Cori::Profiling::InstanceMetrics< T >::GetTotalCreatedCountData ( )
inlinestatic

Retries the data about created instances of type T including derived instances.

Returns
Vector with pairs of string and int64_t, string is the demangled name of the type and int64_t amount of created instances. @detils Example usage: InstanceMetrics<T>::GetTotalCreatedCountData();
Reruns the data about created instances of type T and its derived classes.

Definition at line 115 of file InstanceMetrics.hpp.

Here is the call graph for this function:

◆ Increment()

template<typename T>
void Cori::Profiling::InstanceMetrics< T >::Increment ( )
inlinestaticprotected

Definition at line 135 of file InstanceMetrics.hpp.

◆ RegisterDerivedMetricsProvider()

template<typename T>
void Cori::Profiling::InstanceMetrics< T >::RegisterDerivedMetricsProvider ( const std::type_index & derivedTypeId,
DerivedMetricsProvider provider )
inlinestaticprotected

Definition at line 144 of file InstanceMetrics.hpp.

◆ RegisterDerivedReporter()

template<typename T>
void Cori::Profiling::InstanceMetrics< T >::RegisterDerivedReporter ( const std::type_index & derivedTypeId,
DerivedMetricsReporter reporter )
inlinestaticprotected

Definition at line 151 of file InstanceMetrics.hpp.

◆ Report()

template<typename T>
void Cori::Profiling::InstanceMetrics< T >::Report ( const std::string & indent = "")
inlinestatic

Will report the data about type T instances.

Parameters
indentInitial indentation of the report. @detils Example usage: InstanceMetrics<T>::Report();
Reruns log the data about T and its derived classes.

Definition at line 69 of file InstanceMetrics.hpp.

Here is the call graph for this function:

◆ Trackable

template<typename T>
template<typename DerivedType, typename... BasePack>
friend class Trackable
friend

Definition at line 133 of file InstanceMetrics.hpp.


The documentation for this class was generated from the following file: