-
-
Save boxbeatsy/fda5cfe1eb5af03d5289b63f0bd339fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.apps import apps | |
def profile(): | |
logs = [] | |
for ele in apps.get_models(): | |
model = ele.__name__ | |
name = str(model) | |
hits = cache.get(name+'cachalot_hit',0) | |
tries = cache.get(name+'cachalot_tries',0) | |
size = cache.get(name+'cachalot_size',0) | |
if tries ==0: | |
continue | |
# print model | |
if (tries-hits) > 0: | |
logs += [[ "%s \t\t %s hits / %s tries (avg size: %s KB)" % (model,hits,tries,float(size)/(tries-hits)/1000),float(size)]] | |
else: | |
logs += [[ "%s \t\t %s hits / %s tries" % (model,hits,tries), 0]] | |
logs.sort(key=lambda x: x[1], reverse=True) | |
for ele in logs: | |
print ele[0] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment