profiling
[wolnelektury.git] / apps / wolnelektury_core / management / profile.py
1
2 import cProfile
3 import functools
4
5 _object = None
6
7 def profile(meth):
8     def _wrapper(self, *args, **kwargs):
9         object = self
10         setattr(object, "__%s" % meth.__name__, meth)
11         cProfile.runctx('object.__%s(object, *args, **kwargs)' % (meth.__name__, ), globals(), locals(),
12             "wlprofile")
13
14     functools.update_wrapper(_wrapper, meth)
15     return _wrapper
16