From 1c9fdedbed335dabef64aacd97090797a069bc54 Mon Sep 17 00:00:00 2001 From: Krateng Date: Thu, 21 Nov 2019 06:31:23 +0100 Subject: [PATCH] Added debug output to evaluate PyHP performance --- info.py | 2 +- requirements.txt | 2 +- server.py | 10 ++++++++-- website/artist.pyhp | 6 +++--- website/start.py | 12 ++++++------ 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/info.py b/info.py index 2fb1b82..4fad071 100644 --- a/info.py +++ b/info.py @@ -5,6 +5,6 @@ author = { "email":"maloja@krateng.dev", "github": "krateng" } -version = 1,5,13 +version = 1,5,14 versionstr = ".".join(str(n) for n in version) dev = os.path.exists("./.dev") diff --git a/requirements.txt b/requirements.txt index 4beb6ff..56b4198 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ bottle>=0.12.16 waitress>=1.3 -doreah>=1.2.5 +doreah>=1.2.7 nimrodel>=0.4.9 setproctitle>=1.1.10 wand>=0.5.4 diff --git a/server.py b/server.py index c2437f7..e78e930 100755 --- a/server.py +++ b/server.py @@ -18,6 +18,7 @@ import info # doreah toolkit from doreah import settings from doreah.logging import log +from doreah.timing import Clock # technical from importlib.machinery import SourceFileLoader import _thread @@ -155,6 +156,9 @@ def static_html(name): adminmode = request.cookies.get("adminmode") == "true" and database.checkAPIkey(request.cookies.get("apikey")) is not False + clock = Clock() + clock.start() + # if a pyhp file exists, use this if (pyhp_file and pyhp_pref) or (pyhp_file and not html_file): from doreah.pyhp import file @@ -177,7 +181,9 @@ def static_html(name): environ["filterkeys"], environ["limitkeys"], environ["delimitkeys"], environ["amountkeys"] = uri_to_internal(keys) #response.set_header("Content-Type","application/xhtml+xml") - return file("website/" + name + ".pyhp",environ) + res = file("website/" + name + ".pyhp",environ) + log("Generated page " + name + " in " + str(clock.stop()) + "s (PYHP)",module="debug") + return res # if not, use the old way else: @@ -219,7 +225,7 @@ def static_html(name): response.set_header("Link",",".join(linkheaders)) - + log("Generated page " + name + " in " + str(clock.stop()) + "s (Python+HTML)",module="debug") return html #return static_file("website/" + name + ".html",root="") diff --git a/website/artist.pyhp b/website/artist.pyhp index c4ca8f7..4d22f58 100644 --- a/website/artist.pyhp +++ b/website/artist.pyhp @@ -70,9 +70,9 @@ - diff --git a/website/start.py b/website/start.py index 72e6b7d..246e8b6 100644 --- a/website/start.py +++ b/website/start.py @@ -15,7 +15,7 @@ def instructions(keys): js_command += "showRange('pulse','" + get_settings("DEFAULT_STEP_PULSE") + "');" - clock() + #clock() from malojatime import today,thisweek,thismonth,thisyear @@ -26,7 +26,7 @@ def instructions(keys): topartists_month = module_artistcharts_tiles(timerange=thismonth()) topartists_week = module_artistcharts_tiles(timerange=thisweek()) - clockp("Artists") + #clockp("Artists") # tracks @@ -36,7 +36,7 @@ def instructions(keys): toptracks_week = module_trackcharts_tiles(timerange=thisweek()) - clockp("Tracks") + #clockp("Tracks") @@ -44,7 +44,7 @@ def instructions(keys): # scrobbles html_scrobbles, _, _ = module_scrobblelist(max_=15,shortTimeDesc=True,pictures=True,earlystop=True) - clockp("Scrobbles") + #clockp("Scrobbles") # stats @@ -63,7 +63,7 @@ def instructions(keys): amount_total = database.get_scrobbles_num() scrobbles_total = "" + str(amount_total) + "" - clockp("Amounts") + #clockp("Amounts") # pulse @@ -78,7 +78,7 @@ def instructions(keys): #html_pulse_month = module_pulse(max_=30,since=[dt.year,dt.month],step="day",trail=1) #html_pulse_year = module_pulse(max_=12,since=[dt.year],step="month",trail=1) - clockp("Pulse") + #clockp("Pulse") #pushresources = [{"file":img,"type":"image"} for img in artistimages + trackimages] #can't push scrobble images as we don't get them from the module function, need to think about that pushresources = []