Package elisa :: Package core :: Package utils :: Module profiling
[hide private]
[frames] | no frames]

Source Code for Module elisa.core.utils.profiling

 1  # -*- coding: utf-8 -*- 
 2  # Elisa - Home multimedia server 
 3  # Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com). 
 4  # All rights reserved. 
 5  # 
 6  # This file is available under one of two license agreements. 
 7  # 
 8  # This file is licensed under the GPL version 3. 
 9  # See "LICENSE.GPL" in the root of this distribution including a special 
10  # exception to use Elisa with Fluendo's plugins. 
11  # 
12  # The GPL part of Elisa is also available under a commercial licensing 
13  # agreement from Fluendo. 
14  # See "LICENSE.Elisa" in the root directory of this distribution package 
15  # for details on that license. 
16   
17   
18  __maintainer__ = 'Florian Boucault <florian@fluendo.com>' 
19   
20   
21 -def profileit(printlines=1):
22 import hotshot 23 import hotshot.stats 24 25 def _my(func): 26 def _func(*args, **kargs): 27 prof = hotshot.Profile("profiling.data") 28 res = prof.runcall(func, *args, **kargs) 29 prof.close() 30 stats = hotshot.stats.load("profiling.data") 31 stats.strip_dirs() 32 #stats.sort_stats('cumul', 'calls') 33 #stats.sort_stats('calls', 'cumul') 34 stats.sort_stats('time', 'calls') 35 print ">>>---- Begin profiling print" 36 stats.print_stats(printlines) 37 print ">>>---- End profiling print" 38 return res
39 return _func 40 return _my 41