Pol
Revision:cb584c9
|
#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 |
CPropProfiler & | operator= (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 CPropProfiler & | instance () |
Private Types | |
typedef std::map< const Type, HitsEntries > | Hits |
typedef std::map< const std::string, HitsCounter > | HitsEntries |
typedef std::map< const PropertyList *, const Type > | PropLists |
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 |
Profiler for CProps: stores usage information and computes statistics
Definition at line 47 of file proplist.h.
|
private |
Definition at line 109 of file proplist.h.
|
private |
Definition at line 108 of file proplist.h.
|
private |
Definition at line 107 of file proplist.h.
|
strong |
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.
|
delete |
No copies allowed
|
private |
Definition at line 77 of file proplist.cpp.
|
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().
|
private |
Register a cprop action
proplist | Pointer to the registered list where this cprop resides |
name | Name of the cprop |
key | Index 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
proplist | Pointer to the registered list where this cprop resides |
name | Name of the cprop |
std::runtime_error | When 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
proplist | Pointer to the registered list where this cprop resides |
name | Name 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
proplist | Pointer to the registered list where this cprop resides |
name | Name 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 |
Dumps current status into a given stream
os | The output stream to write into |
Definition at line 214 of file proplist.cpp.
References _hits, _hitsLock, ACCOUNT, Pol::Core::CPropProfiler::HitsCounter::ERASE, GLOBAL, GUILD, ITEM, MOBILE, MULTI, PARTY, Pol::Core::CPropProfiler::HitsCounter::READ, UNKNOWN, and Pol::Core::CPropProfiler::HitsCounter::WRITE.
Referenced by Pol::Module::PolSystemExecutorModule::mf_LogCPropProfile().
size_t Pol::Core::CPropProfiler::estimateSize | ( | ) | const |
Returns the estimated in-memory size of the profiler
Size of base empty containers
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().
|
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().
|
static |
Returns an instance of the profiler, instantiate it on first need
Definition at line 71 of file proplist.cpp.
Referenced by Pol::Core::PropertyList::eraseprop(), Pol::Core::PropertyList::getprop(), Pol::Core::MemoryUsage::log(), Pol::Module::PolSystemExecutorModule::mf_LogCPropProfile(), Pol::Core::PropertyList::PropertyList(), Pol::Core::PolConfig::read_pol_config(), and Pol::Core::PropertyList::setprop().
|
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().
|
delete |
No copies allowed
void Pol::Core::CPropProfiler::registerProplist | ( | const PropertyList * | proplist, |
const Type | type | ||
) |
Registers a property list address
proplist | Pointer to the list to be registered |
type | The 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
proplist | Pointer to the list to be registered |
copiedFrom | Pointer 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.
|
private |
Definition at line 118 of file proplist.h.
Referenced by clear(), dumpProfile(), and estimateSize().
|
mutableprivate |
Definition at line 120 of file proplist.h.
Referenced by clear(), cpropAction(), dumpProfile(), and estimateSize().
|
private |
Definition at line 117 of file proplist.h.
Referenced by clear(), estimateSize(), getProplistType(), registerProplist(), and unregisterProplist().
|
mutableprivate |
Definition at line 119 of file proplist.h.
Referenced by clear(), estimateSize(), getProplistType(), registerProplist(), and unregisterProplist().