X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/f3acfae26c01f08232af6f4b48e9a2ea54a0c2da..153bc4288d5941dafcaca24fe1f4859419d744e0:/apps/wolnelektury_core/management/profile.py diff --git a/apps/wolnelektury_core/management/profile.py b/apps/wolnelektury_core/management/profile.py new file mode 100644 index 000000000..a68453d05 --- /dev/null +++ b/apps/wolnelektury_core/management/profile.py @@ -0,0 +1,16 @@ + +import cProfile +import functools + +_object = None + +def profile(meth): + def _wrapper(self, *args, **kwargs): + object = self + setattr(object, "__%s" % meth.__name__, meth) + cProfile.runctx('object.__%s(object, *args, **kwargs)' % (meth.__name__, ), globals(), locals(), + "wlprofile") + + functools.update_wrapper(_wrapper, meth) + return _wrapper +