• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python psyco.profile函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中psyco.profile函数的典型用法代码示例。如果您正苦于以下问题:Python profile函数的具体用法?Python profile怎么用?Python profile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了profile函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: process_request

 def process_request(self, request):
     try:
         import psyco
         psyco.profile()
     except ImportError:
         pass
     return None
开发者ID:rodbegbie,项目名称:threequarters,代码行数:7,代码来源:middleware.py


示例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())
开发者ID:BackupTheBerlios,项目名称:solipsis-svn,代码行数:26,代码来源:viewport.py


示例3: UsePsyco

def UsePsyco():
    'Tries to use psyco if possible'
    try:
        import psyco
        psyco.profile()
        print "Using psyco"
    except: pass         
开发者ID:AtomAleks,项目名称:PyProp,代码行数:7,代码来源:pyste.py


示例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
开发者ID:larsyencken,项目名称:code-library,代码行数:25,代码来源:escapeUtf8.py


示例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)
开发者ID:BackupTheBerlios,项目名称:slow-svn,代码行数:35,代码来源:tests.py


示例6: _hook

def _hook(*args, **kwargs):
    try:
        import psyco
    except ImportError:
        pass
    else:
        psyco.profile()
开发者ID:BackupTheBerlios,项目名称:skunkweb-svn,代码行数:7,代码来源:psyco_accel.py


示例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:])
开发者ID:Beifeng,项目名称:WTL-DUI,代码行数:59,代码来源:grit_runner.py


示例8: UsePsyco

def UsePsyco():
    "Tries to use psyco if possible"
    try:
        import psyco

        psyco.profile()
    except:
        pass
开发者ID:khongtuong,项目名称:flyffsf,代码行数:8,代码来源:pyste.py


示例9: initPsyco

def initPsyco(psycoProfile=False):
	try:
		import psyco
		if psycoProfile:
			psyco.log()
			psyco.profile()
		else:
			psyco.full()
	except ImportError:
		pass
开发者ID:adamlwgriffiths,项目名称:pystream,代码行数:10,代码来源:scriptsetup.py


示例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()
开发者ID:sabren,项目名称:blaze,代码行数:10,代码来源:main.py


示例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)
开发者ID:sabren,项目名称:blaze,代码行数:11,代码来源:main.py


示例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).")
开发者ID:isislovecruft,项目名称:switzerland,代码行数:11,代码来源:Alice.py


示例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/'
开发者ID:keerthik,项目名称:KRPEngine,代码行数:12,代码来源:startup.py


示例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
开发者ID:cool-RR,项目名称:Miro,代码行数:12,代码来源:Miro.py


示例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()
开发者ID:BackupTheBerlios,项目名称:slow-svn,代码行数:51,代码来源:gui.py


示例16: __init__

	def __init__(self, fileName = None, stream = None):
		import psyco
		psyco.profile()
		self.logger = logging.getLogger("pypsd.psdfile.PSDFile")
		self.logger.debug("__init__ method. In: fileName=%s" % fileName)

		self.stream = stream
		self.fileName = fileName

		self.header = None
		self.colorMode = None
		self.imageResources = None
		self.layerMask = None
		self.imageData = None
开发者ID:aryamansharda,项目名称:pypsd,代码行数:14,代码来源:psdfile.py


示例17: load_psyco

def load_psyco():
    """
    Load psyco library for speedup.
    """
    if HasPsyco:
        import psyco
        # psyco >= 1.4.0 final is needed
        if psyco.__version__ >= 0x10400f0:
            #psyco.log(logfile="psyco.log")
            psyco.profile(memory=10000, memorymax=100000)
        else:
            # warn about old psyco version
            log.warn(LOG_PROXY,
         _("Psyco is installed but not used since the version is too old.\n"
           "Psyco >= 1.4 is needed."))
开发者ID:HomeRad,项目名称:TorCleaner,代码行数:15,代码来源:start.py


示例18: main

def main(argv):
    parser = _create_option_parser()
    (options, args) = parser.parse_args(argv)

    if args:
        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

    check_alignments()
    return
开发者ID:larsyencken,项目名称:kanjitester,代码行数:18,代码来源:check_alignments.py


示例19: main

def main():
    if options.run_shell:
        # Due to univlib init code having been moved into initthread,
        # we must duplicate (ugh!) the univlib initialization code here
        # in order to maintain easiness in shell operations
        # the code is directly copied from LobsterLoader
        # TODO: refactor this once i come up with a solution

        ### START COPY ###
        # init univlib ahead of time
        from gingerprawn.api import univlib

        # FIXED: not hardcoded anymore, can be changed via cmdline
        # default value moved there
        univlib.set_current_univ(_APP_OPTIONS.univ_sel)
        ### END OF COPY ###

        import code

        conzole = code.InteractiveConsole()
        conzole.interact()
        sys.exit(0)

    if not options.do_profiling:
        if options.run_psycoed:
            try:
                import psyco

                logdebug("running Psyco'd")
                psyco.log()
                psyco.profile()
            except ImportError:
                pass
        wxmain()
    else:
        import cProfile

        loginfo("running profiled, starting from here...")
        cProfile.run(
            "wxmain()",
            # profile result destination
            normpath(pathjoin(_PKG_TOPLEV, "launcher/gp-profile")),
        )
开发者ID:xen0n,项目名称:gingerprawn,代码行数:43,代码来源:main.py


示例20: usepsyco

 def usepsyco(self, options):
     # options.psyco == None means the default, which is "full", but don't give a warning...
     # options.psyco == "none" means don't use psyco at all...
     if getattr(options, "psyco", "none") == "none":
         return
     try:
         import psyco
     except Exception:
         if options.psyco is not None:
             self.warning("psyco unavailable", options, sys.exc_info())
         return
     if options.psyco is None:
         options.psyco = "full"
     if options.psyco == "full":
         psyco.full()
     elif options.psyco == "profile":
         psyco.profile()
     # tell psyco the functions it cannot compile, to prevent warnings
     import encodings
     psyco.cannotcompile(encodings.search_function)
开发者ID:AlexArgus,项目名称:affiliates-lib,代码行数:20,代码来源:optrecurse.py



注:本文中的psyco.profile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python gevent.patch_psycopg函数代码示例发布时间:2022-05-25
下一篇:
Python psyco.full函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap