mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2025-11-10 18:36:33 +00:00
Added profiling info
This commit is contained in:
parent
b9817a5617
commit
182809a862
3 changed files with 50 additions and 1 deletions
|
|
@ -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.
|
||||
|
|
|
|||
37
jellyfin_kodi/helper/debug.py
Normal file
37
jellyfin_kodi/helper/debug.py
Normal 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
|
||||
|
||||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue