mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 07:11:52 +00:00
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")
|
||||
|
||||
|
||||
import django
|
||||
print(" - django.setup - next")
|
||||
try:
|
||||
@ -30,9 +29,10 @@ from django.http import HttpResponse
|
||||
from django.urls import reverse
|
||||
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.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
|
||||
|
||||
if os.geteuid() == 0:
|
||||
@ -115,11 +115,11 @@ def memdumpsql(fn):
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# These functions moved to a different file - not used currently.
|
||||
#import logbooksdump
|
||||
#def import_auto_logbooks():
|
||||
#def dumplogbooks():
|
||||
# import logbooksdump
|
||||
# def import_auto_logbooks():
|
||||
# def dumplogbooks():
|
||||
|
||||
#def writeCaves():
|
||||
# def writeCaves():
|
||||
# Writes out all cave and entrance HTML files to
|
||||
# folder specified in settings.CAVEDESCRIPTIONS
|
||||
# for cave in Cave.objects.all():
|
||||
@ -151,12 +151,6 @@ class JobQueue():
|
||||
self.queue.append((label,func))
|
||||
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):
|
||||
"""Load timings for previous runs from file
|
||||
"""
|
||||
@ -182,22 +176,27 @@ class JobQueue():
|
||||
def runqonce(self):
|
||||
"""Run all the jobs in the queue provided - once
|
||||
"""
|
||||
|
||||
print("** Running job ", self.runlabel,end=" to ")
|
||||
print(django.db.connections.databases['default']['NAME'])
|
||||
jobstart = time.time()
|
||||
print("-- Initial memory in use {:.3f} MB".format(get_process_memory()))
|
||||
self.results["date"].pop()
|
||||
self.results["date"].append(jobstart)
|
||||
self.results["runlabel"].pop()
|
||||
self.results["runlabel"].append(self.runlabel)
|
||||
|
||||
for i in self.queue:
|
||||
for runfunction in self.queue:
|
||||
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
|
||||
print("\n*- Ended \"", i[0], "\" %.1f seconds" % duration)
|
||||
self.results[i[0]].pop() # the null item
|
||||
self.results[i[0]].append(duration)
|
||||
#print(" - MEMORY start:{:.3f} MB end:{:.3f} MB change={:.3f} MB".format(memstart,memend, ))
|
||||
print("\n*- Ended \"", runfunction[0], "\" {:.1f} seconds + {:.3f} MB".format(duration, memend-memstart))
|
||||
self.results[runfunction[0]].pop() # the null item
|
||||
self.results[runfunction[0]].append(duration)
|
||||
|
||||
|
||||
jobend = time.time()
|
||||
@ -341,6 +340,8 @@ if __name__ == "__main__":
|
||||
jq.enq("scans",import_surveyscans)
|
||||
elif "survex" in sys.argv:
|
||||
jq.enq("survex",import_survex)
|
||||
elif "loadpos" in sys.argv:
|
||||
jq.enq("survex",import_loadpos)
|
||||
elif "tunnel" in sys.argv:
|
||||
jq.enq("tunnel",import_tunnelfiles)
|
||||
elif "autologbooks" in sys.argv: # untested in 2020
|
||||
|
Loading…
Reference in New Issue
Block a user