Added profiling info

This commit is contained in:
Chuddah 2020-02-18 00:23:19 +00:00
commit 182809a862
3 changed files with 50 additions and 1 deletions

View file

@ -11,7 +11,7 @@ from kodi_six import xbmc
import downloader as server
import helper.xmls as xmls
from database import Database, get_sync, save_sync, jellyfin_db
from helper import translate, settings, window, progress, dialog, LibraryException
from helper import translate, settings, window, progress, dialog, LibraryException, debug
from helper.utils import get_screensaver, set_screensaver
##################################################################################################
@ -249,6 +249,7 @@ class FullSync(object):
raise
@progress()
@debug.profile
def movies(self, library, dialog):
''' Process movies from a single library.

View file

@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
##################################################################################################
import cProfile
import json
import logging
import pstats
import StringIO
##################################################################################################
LOG = logging.getLogger("JELLYFIN." + __name__)
class JsonDebugPrinter(object):
def __init__(self, json):
self.json = json
def __str__(self):
return json.dumps(self.json, indent=4)
def profile(fn):
def profiling_wrapper(*args, **kargs):
pr = cProfile.Profile()
pr.enable()
fn(*args, **kargs)
pr.disable()
s = StringIO.StringIO()
sortby = 'cumulative'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
ps.print_stats()
LOG.debug(s.getvalue())
return profiling_wrapper

View file

@ -15,6 +15,16 @@ LOG = logging.getLogger("JELLYFIN." + __name__)
##################################################################################################
def cache(fn):
CACHE = {}
def cache_wrapper(*args):
try:
result = CACHE[args]
except KeyError:
result = fn(*args)
CACHE[args] = result
return result
return cache_wrapper
class Kodi(object):
@ -155,6 +165,7 @@ class Kodi(object):
return person_id
@cache
def get_person(self, *args):
try: