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


Python time.process_time方法代码示例

本文整理汇总了Python中time.process_time方法的典型用法代码示例。如果您正苦于以下问题:Python time.process_time方法的具体用法?Python time.process_time怎么用?Python time.process_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在time的用法示例。


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

示例1: performance_test__regex_basic_mirrorlization

# 需要导入模块: import time [as 别名]
# 或者: from time import process_time [as 别名]
def performance_test__regex_basic_mirrorlization(self):
        """对 regex_basic_mirrorlization 进行性能测试"""
        from more_configs.config_google_and_zhwikipedia import target_domain, external_domains
        self.reload_zmirror(configs_dict=dict(
            target_domain=target_domain,
            external_domains=external_domains,
        ))
        from time import process_time
        reg_func = self.zmirror.response_text_basic_mirrorlization
        print(self.zmirror.regex_basic_mirrorlization.pattern)

        with open(zmirror_file("tests/sample/google_home.html"), "r", encoding="utf-8") as fp:
            text = fp.read()

        start_time = process_time()
        for _ in range(1000):
            reg_func(text)
        print("100x google_home.html", process_time() - start_time) 
开发者ID:aploium,项目名称:zmirror,代码行数:20,代码来源:test_regex.py

示例2: generate_our_response

# 需要导入模块: import time [as 别名]
# 或者: from time import process_time [as 别名]
def generate_our_response():
    """
    生成我们的响应
    :rtype: Response
    """
    # copy and parse remote response
    resp = copy_response(is_streamed=parse.streamed_our_response)

    if parse.time["req_time_header"] >= 0.00001:
        parse.set_extra_resp_header('X-Header-Req-Time', "%.4f" % parse.time["req_time_header"])
    if parse.time.get("start_time") is not None and not parse.streamed_our_response:
        # remote request time should be excluded when calculating total time
        parse.set_extra_resp_header('X-Body-Req-Time', "%.4f" % parse.time["req_time_body"])
        parse.set_extra_resp_header('X-Compute-Time',
                                    "%.4f" % (process_time() - parse.time["start_time"]))

    parse.set_extra_resp_header('X-Powered-By', 'zmirror/%s' % CONSTS.__VERSION__)

    if developer_dump_all_traffics and not parse.streamed_our_response:
        dump_zmirror_snapshot("traffic")

    return resp 
开发者ID:aploium,项目名称:zmirror,代码行数:24,代码来源:zmirror.py

示例3: run

# 需要导入模块: import time [as 别名]
# 或者: from time import process_time [as 别名]
def run(self) -> None:
        while not self.stop_event.is_set():

            try:
                self.fetch_barrier.wait()
                self.execute_barrier.wait()
                self.execute_barrier.wait()
                self.call_commands()
            except BrokenBarrierError:
                self.fetch_barrier.abort()
                self.execute_barrier.abort()
                self.stop_event.set()
            else:
                tick_time = time.time()
                process_time = time.process_time()
                if self.last_tick_time:
                    self.do_tick(process_time, tick_time)

                self.last_tick_time = tick_time
                self.last_process_time = process_time
                self.tick_count += 1

                if self.tick_interval:
                    sleep_interval = self.tick_interval - self.tick_adjustment
                    sleep(max(sleep_interval, 0)) 
开发者ID:johnbywater,项目名称:eventsourcing,代码行数:27,代码来源:runner.py

示例4: solve

# 需要导入模块: import time [as 别名]
# 或者: from time import process_time [as 别名]
def solve(self, assumptions=[]):
        """
            Solve internal formula.
        """

        if self.cadical:
            if self.use_timer:
                start_time = process_time()

            self.status = pysolvers.cadical_solve(self.cadical, assumptions,
                    int(MainThread.check()))

            if self.use_timer:
                self.call_time = process_time() - start_time
                self.accu_time += self.call_time

            self.prev_assumps = assumptions
            return self.status 
开发者ID:pysathq,项目名称:pysat,代码行数:20,代码来源:solvers.py

示例5: solve_limited

# 需要导入模块: import time [as 别名]
# 或者: from time import process_time [as 别名]
def solve_limited(self, assumptions=[]):
        """
            Solve internal formula using given budgets for conflicts and
            propagations.
        """

        if self.glucose:
            if self.use_timer:
                 start_time = process_time()

            self.status = pysolvers.glucose3_solve_lim(self.glucose,
                    assumptions, int(MainThread.check()))

            if self.use_timer:
                self.call_time = process_time() - start_time
                self.accu_time += self.call_time

            return self.status 
开发者ID:pysathq,项目名称:pysat,代码行数:20,代码来源:solvers.py

示例6: propagate

# 需要导入模块: import time [as 别名]
# 或者: from time import process_time [as 别名]
def propagate(self, assumptions=[], phase_saving=0):
        """
            Propagate a given set of assumption literals.
        """

        if self.glucose:
            if self.use_timer:
                 start_time = process_time()

            st, props = pysolvers.glucose3_propagate(self.glucose,
                    assumptions, phase_saving, int(MainThread.check()))

            if self.use_timer:
                self.call_time = process_time() - start_time
                self.accu_time += self.call_time

            return bool(st), props if props != None else [] 
开发者ID:pysathq,项目名称:pysat,代码行数:19,代码来源:solvers.py

示例7: test_get_clock_info

# 需要导入模块: import time [as 别名]
# 或者: from time import process_time [as 别名]
def test_get_clock_info(self):
        clocks = ['clock', 'perf_counter', 'process_time', 'time']
        if hasattr(time, 'monotonic'):
            clocks.append('monotonic')

        for name in clocks:
            info = time.get_clock_info(name)
            #self.assertIsInstance(info, dict)
            self.assertIsInstance(info.implementation, str)
            self.assertNotEqual(info.implementation, '')
            self.assertIsInstance(info.monotonic, bool)
            self.assertIsInstance(info.resolution, float)
            # 0.0 < resolution <= 1.0
            self.assertGreater(info.resolution, 0.0)
            self.assertLessEqual(info.resolution, 1.0)
            self.assertIsInstance(info.adjustable, bool)

        self.assertRaises(ValueError, time.get_clock_info, 'xxx') 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:20,代码来源:test_time.py

示例8: trace_dispatch

# 需要导入模块: import time [as 别名]
# 或者: from time import process_time [as 别名]
def trace_dispatch(self, frame, event, arg):
        timer = self.timer
        t = timer()
        t = t[0] + t[1] - self.t - self.bias

        if event == "c_call":
            self.c_func_name = arg.__name__

        if self.dispatch[event](self, frame,t):
            t = timer()
            self.t = t[0] + t[1]
        else:
            r = timer()
            self.t = r[0] + r[1] - t # put back unrecorded delta

    # Dispatch routine for best timer program (return = scalar, fastest if
    # an integer but float works too -- and time.process_time() relies on that). 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:19,代码来源:profile.py

示例9: get_active_layer

# 需要导入模块: import time [as 别名]
# 或者: from time import process_time [as 别名]
def get_active_layer(self, actlay, verbose=False):
        """
        This function extracts the active layer based on the underlying stratigraphic architecture.

        Args:
            actlay : active layer elevation based on nodes elevation (m).
            verbose : (bool) when :code:`True`, output additional debug information (default: :code:`False`).
        """

        time0 = time.process_time()
        self.alay = pdalgo.getactlay2(actlay, self.layerThick[:,:self.step+1],
                                    self.depoThick[:,:self.step+1,:])
        if verbose:
            print("   - Get active layer composition ", time.process_time() - time0)
            time0 = time.process_time()

        return 
开发者ID:badlands-model,项目名称:badlands,代码行数:19,代码来源:carbMesh.py

示例10: update_active_layer

# 需要导入模块: import time [as 别名]
# 或者: from time import process_time [as 别名]
def update_active_layer(self, actlayer, elev, verbose=False):
        """
        This function updates the stratigraphic layers based active layer composition.

        Args:
            actlay : active layer elevation based on nodes elevation (m).
            elev : elevation values for TIN nodes.
            verbose : (bool) when :code:`True`, output additional debug information (default: :code:`False`).
        """

        time0 = time.process_time()
        ero = actlayer[:,0]-self.alay[:,0]
        ero[ero>0.] = 0.
        depo = actlayer[:,0]-self.alay[:,0]
        depo[depo<0.] = 0.
        newH, newS = pdalgo.updatecstrati(self.depoThick[:,:self.step+1,:],
                                    self.layerThick[:,:self.step+1], ero, depo)
        self.depoThick[:,:self.step+1,0] = newS
        self.layerThick[:,:self.step+1] = newH
        self.paleoDepth[:,self.step] = elev

        if verbose:
            print("   - Update active layer due to wave-induced erosion/deposition ", time.process_time() - time0)

        return 
开发者ID:badlands-model,项目名称:badlands,代码行数:27,代码来源:carbMesh.py


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