Initial support for pypy + evennia
This commit is contained in:
parent
41859d9e46
commit
5cfff771f2
5 changed files with 59 additions and 37 deletions
|
|
@ -17,7 +17,7 @@ from src.server.sessionhandler import SESSIONS
|
|||
from src.scripts.models import ScriptDB
|
||||
from src.objects.models import ObjectDB
|
||||
from src.players.models import PlayerDB
|
||||
from src.utils import logger, utils, gametime, create
|
||||
from src.utils import logger, utils, gametime, create, is_pypy
|
||||
from src.commands.default.muxcommand import MuxCommand
|
||||
|
||||
# delayed imports
|
||||
|
|
@ -692,24 +692,28 @@ class CmdServerLoad(MuxCommand):
|
|||
for row in ftable:
|
||||
string += "\n " + "{w%s{n" % row[0] + "".join(row[1:])
|
||||
|
||||
# object cache size
|
||||
cachedict = _idmapper.cache_size()
|
||||
totcache = cachedict["_total"]
|
||||
string += "\n{w Database entity (idmapper) cache usage:{n %5.2f MB (%i items)" % (totcache[1], totcache[0])
|
||||
sorted_cache = sorted([(key, tup[0], tup[1]) for key, tup in cachedict.items() if key !="_total" and tup[0] > 0],
|
||||
key=lambda tup: tup[2], reverse=True)
|
||||
table = [[tup[0] for tup in sorted_cache],
|
||||
["%5.2f MB" % tup[2] for tup in sorted_cache],
|
||||
["%i item(s)" % tup[1] for tup in sorted_cache]]
|
||||
ftable = utils.format_table(table, 5)
|
||||
for row in ftable:
|
||||
string += "\n " + row[0] + row[1] + row[2]
|
||||
# get sizes of other caches
|
||||
attr_cache_info, field_cache_info, prop_cache_info = get_cache_sizes()
|
||||
#size = sum([sum([getsizeof(obj) for obj in dic.values()]) for dic in _attribute_cache.values()])/1024.0
|
||||
#count = sum([len(dic) for dic in _attribute_cache.values()])
|
||||
string += "\n{w On-entity Attribute cache usage:{n %5.2f MB (%i attrs)" % (attr_cache_info[1], attr_cache_info[0])
|
||||
string += "\n{w On-entity Field cache usage:{n %5.2f MB (%i fields)" % (field_cache_info[1], field_cache_info[0])
|
||||
string += "\n{w On-entity Property cache usage:{n %5.2f MB (%i props)" % (prop_cache_info[1], prop_cache_info[0])
|
||||
if not is_pypy:
|
||||
# Cache size measurements are not available on PyPy because it lacks sys.getsizeof
|
||||
|
||||
# object cache size
|
||||
cachedict = _idmapper.cache_size()
|
||||
totcache = cachedict["_total"]
|
||||
string += "\n{w Database entity (idmapper) cache usage:{n %5.2f MB (%i items)" % (totcache[1], totcache[0])
|
||||
sorted_cache = sorted([(key, tup[0], tup[1]) for key, tup in cachedict.items() if key !="_total" and tup[0] > 0],
|
||||
key=lambda tup: tup[2], reverse=True)
|
||||
table = [[tup[0] for tup in sorted_cache],
|
||||
["%5.2f MB" % tup[2] for tup in sorted_cache],
|
||||
["%i item(s)" % tup[1] for tup in sorted_cache]]
|
||||
ftable = utils.format_table(table, 5)
|
||||
for row in ftable:
|
||||
string += "\n " + row[0] + row[1] + row[2]
|
||||
# get sizes of other caches
|
||||
attr_cache_info, field_cache_info, prop_cache_info = get_cache_sizes()
|
||||
#size = sum([sum([getsizeof(obj) for obj in dic.values()]) for dic in _attribute_cache.values()])/1024.0
|
||||
#count = sum([len(dic) for dic in _attribute_cache.values()])
|
||||
string += "\n{w On-entity Attribute cache usage:{n %5.2f MB (%i attrs)" % (attr_cache_info[1], attr_cache_info[0])
|
||||
string += "\n{w On-entity Field cache usage:{n %5.2f MB (%i fields)" % (field_cache_info[1], field_cache_info[0])
|
||||
string += "\n{w On-entity Property cache usage:{n %5.2f MB (%i props)" % (prop_cache_info[1], prop_cache_info[0])
|
||||
|
||||
caller.msg(string)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue