当前位置: 首页>>代码示例>>Python>>正文


Python statprof.stop函数代码示例

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


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

示例1: wrapped

 def wrapped(*args, **kwargs):
     statprof.start()
     try:
         return main(*args, **kwargs)
     finally:
         statprof.stop()
         statprof.display(OUT=file(output_file, 'wb'))
开发者ID:offlinehacker,项目名称:flumotion,代码行数:7,代码来源:boot.py

示例2: __exit__

 def __exit__(self, type, value, callback):
     import statprof
     statprof.stop()
     for call in statprof.CallData.all_calls.itervalues():
         trace = _Trace(call)
         for attr in ('percent', 'cumulative', 'self'):
             self.update("{0}.{1}".format(trace.name, attr), getattr(trace, attr))
开发者ID:jdunck,项目名称:metrology,代码行数:7,代码来源:profiler.py

示例3: process_response

    def process_response(self, request, response):
        statprof.stop()
        client = get_client()
        total_samples = statprof.state.sample_count
        if total_samples == 0:
            return response

        secs_per_sample = statprof.state.accumulated_time / total_samples

        def get_struct(c):
            return ({
                'file': c.key.filename,
                'lineno': c.key.lineno,
                'function': c.key.name,
                'type': 'python'
            }, {
                'self_nsamples': c.self_sample_count,
                'cum_nsamples': c.cum_sample_count,
                'tot_nsamples': total_samples,
                'cum_time': c.cum_sample_count * secs_per_sample,
                'self_time': c.self_sample_count * secs_per_sample
            })

        client.insert_all([get_struct(c)
                           for c in statprof.CallData.all_calls.itervalues()])

        return response
开发者ID:ildus,项目名称:django-live-profiler,代码行数:27,代码来源:middleware.py

示例4: process_response

    def process_response(self, request, response):
        statprof.stop()
        client = get_client()
        total_samples = statprof.state.sample_count

        if total_samples == 0:
            return response

        secs_per_sample = statprof.state.accumulated_time / total_samples

        client.insert_all(
            [
                (
                    {"file": c.key.filename, "lineno": c.key.lineno, "function": c.key.name, "type": "python"},
                    {
                        "self_nsamples": c.self_sample_count,
                        "cum_nsamples": c.cum_sample_count,
                        "tot_nsamples": total_samples,
                        "cum_time": c.cum_sample_count * secs_per_sample,
                        "self_time": c.self_sample_count * secs_per_sample,
                    },
                )
                for c in statprof.CallData.all_calls.itervalues()
            ]
        )

        return response
开发者ID:natebeacham,项目名称:django-live-profiler,代码行数:27,代码来源:middleware.py

示例5: stat

      def stat():
         if options.profile:
            statprof.stop()

         output = StringIO.StringIO()
         output.write("-" * 80)
         output.write("\nWorker with PID %s processed %d requests\n"  % (workerPid, site.cnt))

         if options.profile:
            output.write("\n")
            #format = statprof.DisplayFormats.ByLine
            #format = statprof.DisplayFormats.ByMethod
            #statprof.display(output, format = format)
            statprof.display(output)

         output.write("-" * 80)
         output.write("\n")
         output.write("\n")

         sys.stdout.write(output.getvalue())

         if options.profile:
            statprof.reset()
            statprof.start()

         reactor.callLater(options.interval, stat)
开发者ID:luodaobin,项目名称:scratchbox,代码行数:26,代码来源:server.py

示例6: inner

 def inner(*args, **kwargs):
     statprof.reset(frequency=1000)
     statprof.start()
     try:
         return fn(*args, **kwargs)
     finally:
         statprof.stop()
         statprof.display()
开发者ID:lopuhin,项目名称:python-adagram,代码行数:8,代码来源:utils.py

示例7: catching

 def catching(proc, *args, **kwargs):
     import statprof
     statprof.start()
     try:
         return proc(*args, **kwargs)
     finally:
         statprof.stop()
         statprof.display()
开发者ID:flyapen,项目名称:UgFlu,代码行数:8,代码来源:boot.py

示例8: pilot_detail

def pilot_detail(request, pilot_id):
    return pilot_detail_view.pilot_detail(request, pilot_id)
    statprof.start()
    try:
        return pilot_detail_view.pilot_detail(request, pilot_id)
    finally:
        statprof.stop()
        statprof.display()
    return pilot_detail_view.pilot_detail(request, pilot_id)
    return render(request, "analizer/index.html", {"error_message": "Unsupported: "})
开发者ID:despair1,项目名称:zk_dj,代码行数:10,代码来源:views.py

示例9: inner

 def inner(*args, **kwargs):
     if deco_kwargs.get('traceback'):
         traceback.print_stack()
     print('starting %s' % fn.__name__)
     start = time.time()
     stat_profile = deco_kwargs.get('stat_profile')
     if stat_profile:
         import statprof
         statprof.reset(frequency=10000)
         statprof.start()
     fn(*args, **kwargs)
     fn_time = time.time() - start
     print('finished %s in %s s' % (fn.__name__, fn_time))
     if stat_profile:
         statprof.stop()
         statprof.display()
     return fn_time
开发者ID:chtd,项目名称:psycopg2-benchmarks,代码行数:17,代码来源:utils.py

示例10: statprofile

def statprofile(ui, func, fp):
    try:
        import statprof
    except ImportError:
        raise util.Abort(_('statprof not available - install using "easy_install statprof"'))

    freq = ui.configint("profiling", "freq", default=1000)
    if freq > 0:
        statprof.reset(freq)
    else:
        ui.warn(_("invalid sampling frequency '%s' - ignoring\n") % freq)

    statprof.start()
    try:
        return func()
    finally:
        statprof.stop()
        statprof.display(fp)
开发者ID:CSCI-362-02-2015,项目名称:RedTeam,代码行数:18,代码来源:dispatch.py

示例11: run

def run(main, profile=None):
    if not profile:
        main()
        return

    if profile == 'hotshot':
        import hotshot, hotshot.stats
        p = hotshot.Profile("/tmp/pro")
        p.runcall(main)
        p.close()
        hotshot.stats.load("/tmp/pro").sort_stats('cumulative').print_stats()
    elif profile == 'stat':
        import statprof
        statprof.start()
        try:
            main()
        finally:
            statprof.stop()
            statprof.display()
开发者ID:drewp,项目名称:light9,代码行数:19,代码来源:prof.py

示例12: statprofile

def statprofile(ui, fp):
    try:
        import statprof
    except ImportError:
        raise error.Abort(_(
            'statprof not available - install using "easy_install statprof"'))

    freq = ui.configint('profiling', 'freq', default=1000)
    if freq > 0:
        # Cannot reset when profiler is already active. So silently no-op.
        if statprof.state.profile_level == 0:
            statprof.reset(freq)
    else:
        ui.warn(_("invalid sampling frequency '%s' - ignoring\n") % freq)

    statprof.start()
    try:
        yield
    finally:
        statprof.stop()
        statprof.display(fp)
开发者ID:motlin,项目名称:cyg,代码行数:21,代码来源:profiling.py

示例13: test_profiling_output_contains_file_names_formatted_appropriately

def test_profiling_output_contains_file_names_formatted_appropriately():
    start()

    def fun():
        for i in range(2 ** 20):
            pass

    def fun2():
        for i in range(50):
            fun()

    fun2()
    stop()

    for format in (DisplayFormat.BY_LINE, DisplayFormat.BY_METHOD):
        full_path = abspath(__file__)
        base = basename(__file__)

        content = get_output(format=format, path_format=PathFormat.FULL_PATH)
        assert full_path in content

        content = get_output(format=format, path_format=PathFormat.FILENAME_ONLY)
        assert base in content
        assert full_path not in content
开发者ID:anntzer,项目名称:statprof.py,代码行数:24,代码来源:test_statprof.py

示例14: stat

      def stat():
         if options.profile:
            statprof.stop()

         output = StringIO.StringIO()
         output.write("-" * 80 + "\n")
         output.write("Worker Statistics (PID %s)\n\n%s"  % (workerPid, factory.stats.stats()))

         if options.profile:
            output.write("\n")
            #format = statprof.DisplayFormats.ByLine
            #format = statprof.DisplayFormats.ByMethod
            #statprof.display(output, format = format)
            statprof.display(output)

         output.write("-" * 80 + "\n\n")

         sys.stdout.write(output.getvalue())

         if options.profile:
            statprof.reset(PROFILER_FREQ)
            statprof.start()

         reactor.callLater(options.interval, stat)
开发者ID:EricSchles,项目名称:AutobahnPython,代码行数:24,代码来源:server.py

示例15: generateOrders

def generateOrders():  # pylint: disable=invalid-name
    """Called once per turn to tell the Python AI to generate and issue orders to control its empire.
    at end of this function, fo.doneTurn() should be called to indicate to the client that orders are finished
    and can be sent to the server for processing."""
    empire = fo.getEmpire()
    if empire.eliminated:
        print "This empire has been eliminated. Aborting order generation"
        try:
            # early abort if already eliminated. no need to do meter calculations
            # on last-seen gamestate if nothing can be ordered anyway...
            fo.doneTurn()
        except Exception as e:
            print_error(e)
        return

    # This code block is required for correct AI work.
    print "Meter / Resource Pool updating..."
    fo.initMeterEstimatesDiscrepancies()
    fo.updateMeterEstimates(0)
    fo.updateResourcePools()

    turn = fo.currentTurn()
    turn_uid = foAIstate.set_turn_uid()
    print "Start turn %s (%s) of game: %s" % (turn, turn_uid, foAIstate.uid)

    turn_timer.start("AI planning")
    # set the random seed (based on galaxy seed, empire name and current turn)
    # for game-reload consistency.
    random_seed = str(fo.getGalaxySetupData().seed) + "%05d%s" % (turn, fo.getEmpire().name)
    random.seed(random_seed)
    aggression_name = fo.aggression.values[foAIstate.aggression].name
    if turn == 1:
        declare_war_on_all()
        human_player = fo.empirePlayerID(1)
        fo.sendChatMessage(human_player,  '%s Empire (%s):\n"Ave, Human, morituri te salutant!"' % (empire.name, aggression_name))

    # turn cleanup !!! this was formerly done at start of every turn -- not sure why
    foAIstate.split_new_fleets()

    foAIstate.refresh()  # checks exploration border & clears roles/missions of missing fleets & updates fleet locs & threats
    foAIstate.report_system_threats()
    print("Calling AI Modules")
    # call AI modules
    action_list = [ColonisationAI.survey_universe,
                   ProductionAI.find_best_designs_this_turn,
                   PriorityAI.calculate_priorities,
                   ExplorationAI.assign_scouts_to_explore_systems,
                   ColonisationAI.assign_colony_fleets_to_colonise,
                   InvasionAI.assign_invasion_fleets_to_invade,
                   MilitaryAI.assign_military_fleets_to_systems,
                   FleetUtilsAI.generate_fleet_orders_for_fleet_missions,
                   FleetUtilsAI.issue_fleet_orders_for_fleet_missions,
                   ResearchAI.generate_research_orders,
                   ProductionAI.generateProductionOrders,
                   ResourcesAI.generate_resources_orders,
                   foAIstate.after_turn_cleanup,
                   ]

    for action in action_list:
        try:
            main_timer.start(action.__name__)
            action()
            main_timer.stop()
        except Exception as e:
            print_error(e, location=action.__name__)
    main_timer.end()
    turn_timer.end()
    turn_timer.start("Server_Processing")

    try:
        fo.doneTurn()
    except Exception as e:
        print_error(e)  # TODO move it to cycle above

    if using_statprof:
        try:
            statprof.stop()
            statprof.display()
            statprof.start()
        except:
            pass
开发者ID:PanchoWW,项目名称:Learnorion,代码行数:81,代码来源:FreeOrionAI.py


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