forked from expo/troggle
add memory footprint display
This commit is contained in:
parent
39f042240d
commit
c4e2ae2395
@ -10,7 +10,6 @@ os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
|
|||||||
|
|
||||||
print(" - settings on loading databaseReset.py")
|
print(" - settings on loading databaseReset.py")
|
||||||
|
|
||||||
|
|
||||||
import django
|
import django
|
||||||
print(" - django.setup - next")
|
print(" - django.setup - next")
|
||||||
try:
|
try:
|
||||||
@ -30,9 +29,10 @@ from django.http import HttpResponse
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
from troggle.core.models import get_process_memory
|
||||||
from troggle.core.models_caves import Cave, Entrance
|
from troggle.core.models_caves import Cave, Entrance
|
||||||
from troggle.parsers.imports import import_caves, import_people, import_surveyscans, \
|
from troggle.parsers.imports import import_caves, import_people, import_surveyscans, \
|
||||||
import_logbooks, import_QMs, import_survex, import_tunnelfiles
|
import_logbooks, import_QMs, import_survex, import_loadpos, import_tunnelfiles
|
||||||
import troggle.logbooksdump
|
import troggle.logbooksdump
|
||||||
|
|
||||||
if os.geteuid() == 0:
|
if os.geteuid() == 0:
|
||||||
@ -115,11 +115,11 @@ def memdumpsql(fn):
|
|||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# These functions moved to a different file - not used currently.
|
# These functions moved to a different file - not used currently.
|
||||||
#import logbooksdump
|
# import logbooksdump
|
||||||
#def import_auto_logbooks():
|
# def import_auto_logbooks():
|
||||||
#def dumplogbooks():
|
# def dumplogbooks():
|
||||||
|
|
||||||
#def writeCaves():
|
# def writeCaves():
|
||||||
# Writes out all cave and entrance HTML files to
|
# Writes out all cave and entrance HTML files to
|
||||||
# folder specified in settings.CAVEDESCRIPTIONS
|
# folder specified in settings.CAVEDESCRIPTIONS
|
||||||
# for cave in Cave.objects.all():
|
# for cave in Cave.objects.all():
|
||||||
@ -151,12 +151,6 @@ class JobQueue():
|
|||||||
self.queue.append((label,func))
|
self.queue.append((label,func))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
#Removing the last element from the queue - dequeue
|
|
||||||
# def deq(self):
|
|
||||||
# if len(self.queue)>0:
|
|
||||||
# return self.queue.pop()
|
|
||||||
# return ("Queue Empty!")
|
|
||||||
|
|
||||||
def loadprofiles(self):
|
def loadprofiles(self):
|
||||||
"""Load timings for previous runs from file
|
"""Load timings for previous runs from file
|
||||||
"""
|
"""
|
||||||
@ -182,22 +176,27 @@ class JobQueue():
|
|||||||
def runqonce(self):
|
def runqonce(self):
|
||||||
"""Run all the jobs in the queue provided - once
|
"""Run all the jobs in the queue provided - once
|
||||||
"""
|
"""
|
||||||
|
|
||||||
print("** Running job ", self.runlabel,end=" to ")
|
print("** Running job ", self.runlabel,end=" to ")
|
||||||
print(django.db.connections.databases['default']['NAME'])
|
print(django.db.connections.databases['default']['NAME'])
|
||||||
jobstart = time.time()
|
jobstart = time.time()
|
||||||
|
print("-- Initial memory in use {:.3f} MB".format(get_process_memory()))
|
||||||
self.results["date"].pop()
|
self.results["date"].pop()
|
||||||
self.results["date"].append(jobstart)
|
self.results["date"].append(jobstart)
|
||||||
self.results["runlabel"].pop()
|
self.results["runlabel"].pop()
|
||||||
self.results["runlabel"].append(self.runlabel)
|
self.results["runlabel"].append(self.runlabel)
|
||||||
|
|
||||||
for i in self.queue:
|
for runfunction in self.queue:
|
||||||
start = time.time()
|
start = time.time()
|
||||||
i[1]() # looks ugly but invokes function passed in the second item in the tuple
|
memstart = get_process_memory()
|
||||||
|
#--------------------
|
||||||
|
runfunction[1]() # invokes function passed in the second item in the tuple
|
||||||
|
#--------------------
|
||||||
|
memend = get_process_memory()
|
||||||
duration = time.time()-start
|
duration = time.time()-start
|
||||||
print("\n*- Ended \"", i[0], "\" %.1f seconds" % duration)
|
#print(" - MEMORY start:{:.3f} MB end:{:.3f} MB change={:.3f} MB".format(memstart,memend, ))
|
||||||
self.results[i[0]].pop() # the null item
|
print("\n*- Ended \"", runfunction[0], "\" {:.1f} seconds + {:.3f} MB".format(duration, memend-memstart))
|
||||||
self.results[i[0]].append(duration)
|
self.results[runfunction[0]].pop() # the null item
|
||||||
|
self.results[runfunction[0]].append(duration)
|
||||||
|
|
||||||
|
|
||||||
jobend = time.time()
|
jobend = time.time()
|
||||||
@ -341,6 +340,8 @@ if __name__ == "__main__":
|
|||||||
jq.enq("scans",import_surveyscans)
|
jq.enq("scans",import_surveyscans)
|
||||||
elif "survex" in sys.argv:
|
elif "survex" in sys.argv:
|
||||||
jq.enq("survex",import_survex)
|
jq.enq("survex",import_survex)
|
||||||
|
elif "loadpos" in sys.argv:
|
||||||
|
jq.enq("survex",import_loadpos)
|
||||||
elif "tunnel" in sys.argv:
|
elif "tunnel" in sys.argv:
|
||||||
jq.enq("tunnel",import_tunnelfiles)
|
jq.enq("tunnel",import_tunnelfiles)
|
||||||
elif "autologbooks" in sys.argv: # untested in 2020
|
elif "autologbooks" in sys.argv: # untested in 2020
|
||||||
|
Loading…
x
Reference in New Issue
Block a user