Pol  Revision:4b29d2b
Pol::Core::CPropProfiler Class Reference

#include <proplist.h>

Classes

class  HitsCounter
 

Public Types

enum  Type : u8 {
  Type::ACCOUNT, Type::GUILD, Type::GLOBAL, Type::ITEM,
  Type::MOBILE, Type::MULTI, Type::PARTY, Type::DATAFILEELEMENT,
  Type::REGION, Type::UNKNOWN
}
 

Public Member Functions

 CPropProfiler (const CPropProfiler &)=delete
 
void clear ()
 
void cpropErase (const PropertyList *proplist, const std::string &name)
 
void cpropRead (const PropertyList *proplist, const std::string &name)
 
void cpropWrite (const PropertyList *proplist, const std::string &name)
 
void dumpProfile (std::ostream &os) const
 
size_t estimateSize () const
 
CPropProfileroperator= (const CPropProfiler &)=delete
 
void registerProplist (const PropertyList *proplist, const Type type)
 
void registerProplist (const PropertyList *proplist, const PropertyList *copiedFrom)
 
void unregisterProplist (const PropertyList *proplist)
 

Static Public Member Functions

static Type class_to_type (UOBJ_CLASS oclass)
 
static CPropProfilerinstance ()
 

Private Types

typedef std::map< const Type, HitsEntriesHits
 
typedef std::map< const std::string, HitsCounterHitsEntries
 
typedef std::map< const PropertyList *, const TypePropLists
 

Private Member Functions

 CPropProfiler ()
 
void cpropAction (const PropertyList *proplist, const std::string &name, const size_t key)
 
Type getProplistType (const PropertyList *proplist) const
 
bool isIgnored (Type type) const
 

Private Attributes

std::unique_ptr< Hits_hits
 
Clib::SpinLock _hitsLock
 
std::unique_ptr< PropLists_proplists
 
Clib::SpinLock _proplistsLock
 

Detailed Description

Profiler for CProps: stores usage information and computes statistics

Author
Bodom

Definition at line 47 of file proplist.h.

Member Typedef Documentation

typedef std::map<const Type, HitsEntries> Pol::Core::CPropProfiler::Hits
private

Definition at line 109 of file proplist.h.

typedef std::map<const std::string, HitsCounter> Pol::Core::CPropProfiler::HitsEntries
private

Definition at line 108 of file proplist.h.

typedef std::map<const PropertyList*, const Type> Pol::Core::CPropProfiler::PropLists
private

Definition at line 107 of file proplist.h.

Member Enumeration Documentation

Type of CProp, for profiling

Enumerator
ACCOUNT 
GUILD 
GLOBAL 
ITEM 
MOBILE 
MULTI 
PARTY 
DATAFILEELEMENT 
REGION 
UNKNOWN 

unknown type, do not use (internally used when profiler is enabled after startup)

Definition at line 53 of file proplist.h.

Constructor & Destructor Documentation

Pol::Core::CPropProfiler::CPropProfiler ( const CPropProfiler )
delete

No copies allowed

Pol::Core::CPropProfiler::CPropProfiler ( )
private

Definition at line 77 of file proplist.cpp.

Member Function Documentation

CPropProfiler::Type Pol::Core::CPropProfiler::class_to_type ( UOBJ_CLASS  oclass)
static

Given an UOBJ_CLASS, returns the corresponding Type for profiling

Must compute all cases, relying on GCC's -wSwitch option to check it but placing a safe fallback anyway.

Definition at line 48 of file proplist.cpp.

References Pol::Core::CLASS_ARMOR, Pol::Core::CLASS_CHARACTER, Pol::Core::CLASS_CONTAINER, Pol::Core::CLASS_ITEM, Pol::Core::CLASS_MULTI, Pol::Core::CLASS_NPC, Pol::Core::CLASS_WEAPON, Pol::Core::INVALID, ITEM, MOBILE, MULTI, and UNKNOWN.

void Pol::Core::CPropProfiler::clear ( )

Discards all the gathered data

Definition at line 200 of file proplist.cpp.

References _hits, _hitsLock, _proplists, and _proplistsLock.

Referenced by Pol::Core::PolConfig::read_pol_config().

void Pol::Core::CPropProfiler::cpropAction ( const PropertyList proplist,
const std::string &  name,
const size_t  key 
)
private

Register a cprop action

Parameters
proplistPointer to the registered list where this cprop resides
nameName of the cprop
keyIndex of the array key to update

Definition at line 182 of file proplist.cpp.

References _hitsLock, getProplistType(), isIgnored(), and name.

Referenced by cpropErase(), cpropRead(), and cpropWrite().

void Pol::Core::CPropProfiler::cpropErase ( const PropertyList proplist,
const std::string &  name 
)

Register a cprop erase

Parameters
proplistPointer to the registered list where this cprop resides
nameName of the cprop
Exceptions
std::runtime_errorWhen proplist is not registered

Definition at line 138 of file proplist.cpp.

References cpropAction(), and Pol::Core::CPropProfiler::HitsCounter::ERASE.

Referenced by Pol::Core::PropertyList::eraseprop().

void Pol::Core::CPropProfiler::cpropRead ( const PropertyList proplist,
const std::string &  name 
)

Register a cprop read

Parameters
proplistPointer to the registered list where this cprop resides
nameName of the cprop

Definition at line 117 of file proplist.cpp.

References cpropAction(), and Pol::Core::CPropProfiler::HitsCounter::READ.

Referenced by Pol::Core::PropertyList::getprop().

void Pol::Core::CPropProfiler::cpropWrite ( const PropertyList proplist,
const std::string &  name 
)

Register a cprop write

Parameters
proplistPointer to the registered list where this cprop resides
nameName of the cprop

Definition at line 127 of file proplist.cpp.

References cpropAction(), and Pol::Core::CPropProfiler::HitsCounter::WRITE.

Referenced by Pol::Core::PropertyList::setprop().

void Pol::Core::CPropProfiler::dumpProfile ( std::ostream &  os) const
size_t Pol::Core::CPropProfiler::estimateSize ( ) const

Returns the estimated in-memory size of the profiler

Size of base empty containers

  • size of proplists
  • size of hits

Definition at line 303 of file proplist.cpp.

References _hits, _hitsLock, _proplists, and _proplistsLock.

Referenced by Pol::Core::MemoryUsage::log(), and Pol::Module::PolSystemExecutorModule::mf_LogCPropProfile().

CPropProfiler::Type Pol::Core::CPropProfiler::getProplistType ( const PropertyList proplist) const
private

Returns proplist type, internal usage

Unknown should happen only when the profiler has been disabled and then re-enabled (including when it was disabled at startup and enabled later). In any other case, it's a bug.

Definition at line 82 of file proplist.cpp.

References _proplists, _proplistsLock, and UNKNOWN.

Referenced by cpropAction(), and registerProplist().

bool Pol::Core::CPropProfiler::isIgnored ( Type  type) const
private

Returns wether a given type should be ignored, intenal usage

Definition at line 104 of file proplist.cpp.

References DATAFILEELEMENT, and REGION.

Referenced by cpropAction().

CPropProfiler& Pol::Core::CPropProfiler::operator= ( const CPropProfiler )
delete

No copies allowed

void Pol::Core::CPropProfiler::registerProplist ( const PropertyList proplist,
const Type  type 
)

Registers a property list address

Parameters
proplistPointer to the list to be registered
typeThe type of the list to be registered

Definition at line 149 of file proplist.cpp.

References _proplists, and _proplistsLock.

Referenced by Pol::Core::PropertyList::PropertyList(), and registerProplist().

void Pol::Core::CPropProfiler::registerProplist ( const PropertyList proplist,
const PropertyList copiedFrom 
)

Registers a property list with same type of an already registered one

Parameters
proplistPointer to the list to be registered
copiedFromPointer to the already registered list to copy the type from

Definition at line 161 of file proplist.cpp.

References getProplistType(), and registerProplist().

void Pol::Core::CPropProfiler::unregisterProplist ( const PropertyList proplist)

Unregisters a property list address

Definition at line 169 of file proplist.cpp.

References _proplists, and _proplistsLock.

Member Data Documentation

std::unique_ptr<Hits> Pol::Core::CPropProfiler::_hits
private

Definition at line 118 of file proplist.h.

Referenced by clear(), dumpProfile(), and estimateSize().

Clib::SpinLock Pol::Core::CPropProfiler::_hitsLock
mutableprivate

Definition at line 120 of file proplist.h.

Referenced by clear(), cpropAction(), dumpProfile(), and estimateSize().

std::unique_ptr<PropLists> Pol::Core::CPropProfiler::_proplists
private
Clib::SpinLock Pol::Core::CPropProfiler::_proplistsLock
mutableprivate

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