本文整理汇总了Python中psyco.profile函数的典型用法代码示例。如果您正苦于以下问题:Python profile函数的具体用法?Python profile怎么用?Python profile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了profile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_request
def process_request(self, request):
try:
import psyco
psyco.profile()
except ImportError:
pass
return None
示例2: __test
def __test():
import psyco
psyco.profile()
class W(object):
def GetClientSizeTuple(self):
return (640,480)
class O(object):
pass
w = W()
v = Viewport(w)
v.SetCenter((50, 3000))
objects = [ ( "a", 12555, -256 ),
( "b", 123, 7885 ),
( "c", -45645, 0 ),
( "d", 235, 66 ),
]
for i in xrange(5):
for name, x, y in objects:
v.Add(name + str(i), O(), position=(x, y))
print v._Ratio(v._Indices())
for i in xrange(50000):
v._ConvertPositions(v._Indices())
print v._ConvertPositions(v._Indices())
示例3: UsePsyco
def UsePsyco():
'Tries to use psyco if possible'
try:
import psyco
psyco.profile()
print "Using psyco"
except: pass
示例4: main
def main(argv):
"""The main method for this module."""
parser = _createOptionParser()
(options, args) = parser.parse_args(argv)
try:
[inputFile, outputFile] = args
except:
parser.print_help()
sys.exit(1)
# Avoid psyco in debugging mode, since it merges stack frames.
if not options.debug:
try:
import psyco
psyco.profile()
except:
pass
if options.escape:
escapeUtf8(inputFile, outputFile)
else:
unescapeUtf8(inputFile, outputFile)
return
示例5: run_or_profile
def run_or_profile(suite):
runner = unittest.TextTestRunner(verbosity=2)
args = sys.argv[1:]
if '-P' in args or '-PP' in args:
try:
import psyco
if '-PP' in sys.argv[1:]:
psyco.profile()
else:
psyco.full()
print "Using Psyco."
except:
pass
if '-p' in args:
import os, hotshot, hotshot.stats
LOG_FILE="profile.log"
profiler = hotshot.Profile(LOG_FILE)
profiler.runcall(runner.run, suite)
profiler.close()
stats = hotshot.stats.load(LOG_FILE)
stats.strip_dirs()
stats.sort_stats('time', 'calls')
stats.print_stats(60)
try:
os.unlink(LOG_FILE)
except:
pass
else:
runner.run(suite)
示例6: _hook
def _hook(*args, **kwargs):
try:
import psyco
except ImportError:
pass
else:
psyco.profile()
示例7: Main
def Main(args):
"""Parses arguments and does the appropriate thing."""
util.ChangeStdoutEncoding()
if sys.version_info < (2, 6):
print "GRIT requires Python 2.6 or later."
return 2
elif not args or (len(args) == 1 and args[0] == 'help'):
PrintUsage()
return 0
elif len(args) == 2 and args[0] == 'help':
tool = args[1].lower()
if not _GetToolInfo(tool):
print "No such tool. Try running 'grit help' for a list of tools."
return 2
print ("Help for 'grit %s' (for general help, run 'grit help'):\n"
% (tool))
print _GetToolInfo(tool)[_FACTORY]().__doc__
return 0
else:
options = Options()
args = options.ReadOptions(args) # args may be shorter after this
if not args:
print "No tool provided. Try running 'grit help' for a list of tools."
return 2
tool = args[0]
if not _GetToolInfo(tool):
print "No such tool. Try running 'grit help' for a list of tools."
return 2
try:
if _GetToolInfo(tool)[_REQUIRES_INPUT]:
os.stat(options.input)
except OSError:
print ('Input file %s not found.\n'
'To specify a different input file:\n'
' 1. Use the GRIT_INPUT environment variable.\n'
' 2. Use the -i command-line option. This overrides '
'GRIT_INPUT.\n'
' 3. Specify neither GRIT_INPUT or -i and GRIT will try to load '
"'resource.grd'\n"
' from the current directory.' % options.input)
return 2
if options.psyco:
# Psyco is a specializing JIT for Python. Early tests indicate that it
# could speed up GRIT (at the expense of more memory) for large GRIT
# compilations. See http://psyco.sourceforge.net/
import psyco
psyco.profile()
toolobject = _GetToolInfo(tool)[_FACTORY]()
if options.profile_dest:
import hotshot
prof = hotshot.Profile(options.profile_dest)
prof.runcall(toolobject.Run, options, args[1:])
else:
toolobject.Run(options, args[1:])
示例8: UsePsyco
def UsePsyco():
"Tries to use psyco if possible"
try:
import psyco
psyco.profile()
except:
pass
示例9: initPsyco
def initPsyco(psycoProfile=False):
try:
import psyco
if psycoProfile:
psyco.log()
psyco.profile()
else:
psyco.full()
except ImportError:
pass
示例10: run
def run():
try:
import psyco
psyco.profile()
except ImportError:
print 'psyco not found! If your game runs slowly try installing \
it from http://psyco.sourceforge.net.'
e = Game(20)
e.DEFAULT = menus.MainMenu
e.run()
示例11: __init__
def __init__(self, fps=40):
Engine.__init__(self, fps)
try:
import psyco
psyco.profile()
except ImportError:
print "psyco not detected, if your game runs slowly try installing \
it from http://psyco.sourceforge.net."
pygame.display.set_caption("Ascent of Justice")
pygame.display.set_icon(data.icon)
示例12: start
def start(self):
"Launch various sub-threads."
#self.listener.start()
self.reporter.start()
if self.config.do_cleaning:
self.cleaner.start()
try:
import psyco
psyco.profile()
except ImportError:
log.info("The psyco package is unavailable (that's okay, but the client is more\nefficient if psyco is installed).")
示例13: Main
def Main(data_dir):
print "Now checking your Python environment:"
Check_Version()
# Psyco is optional, but recommended :)
if ( True ):
try:
import psyco
psyco.profile()
except Exception, r:
print 'Psyco not found. If the game runs too slowly, '
print 'install Psyco from http://psyco.sf.net/'
示例14: activate_psyco
def activate_psyco():
# Get cpu type
info = os.uname()
cpu = info[-1]
# Activate only if we are on an Intel Mac.
if cpu == 'i386':
try:
import psyco
psyco.profile()
except:
pass
示例15: run
def run():
import sys, optparse
app = qt.QApplication(sys.argv)
opparser = optparse.OptionParser()
opparser.add_option('-l', '--logfile', dest='logfile',
help="write log to FILE", metavar='FILE')
opparser.add_option('-d', '--loglevel', dest='loglevel',
help="set log level", default='ERROR')
opparser.add_option('-L', '--language', dest='language',
help="set user interface language")
opparser.add_option('-P', '--no-psyco', dest='psyco_off',
action='store_true', default=False,
help="set user interface language")
options, args = opparser.parse_args( app.argv() )
if not options.psyco_off:
try:
import psyco
psyco.profile()
RUNNING_PSYCO = True
except ImportError:
pass
loglevel = getattr(logging, options.loglevel.upper(), logging.ERROR)
if options.logfile:
logging.basicConfig(level=loglevel,
filename=options.logfile, filemode='w')
else:
logging.basicConfig(level=loglevel)
if options.language:
translator = qt.QTranslator()
if translator.load('gui_%s' % options.language, 'qtgui/ts'):
app.installTranslator(translator)
# setup GUI
qt.QObject.connect(app, qt.SIGNAL("lastWindowClosed()"), app, qt.SLOT("quit()"))
w = OverlayDesigner_gui()
app.setMainWidget(w)
w.show()
if len(args) > 1:
w.loadFile(args[1])
app.exec_loop()