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


Python time.get_clock_info方法代码示例

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


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

示例1: collect_time

# 需要导入模块: import time [as 别名]
# 或者: from time import get_clock_info [as 别名]
def collect_time(info_add):
    import time

    info_add('time.time', time.time())

    attributes = (
        'altzone',
        'daylight',
        'timezone',
        'tzname',
    )
    copy_attributes(info_add, time, 'time.%s', attributes)

    if hasattr(time, 'get_clock_info'):
        for clock in ('clock', 'monotonic', 'perf_counter',
                      'process_time', 'thread_time', 'time'):
            try:
                # prevent DeprecatingWarning on get_clock_info('clock')
                with warnings.catch_warnings(record=True):
                    clock_info = time.get_clock_info(clock)
            except ValueError:
                # missing clock like time.thread_time()
                pass
            else:
                info_add('time.get_clock_info(%s)' % clock, clock_info) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:27,代码来源:pythoninfo.py

示例2: __init__

# 需要导入模块: import time [as 别名]
# 或者: from time import get_clock_info [as 别名]
def __init__(self):
        self._timer_cancelled_count = 0
        self._closed = False
        self._stopping = False
        self._ready = collections.deque()
        self._scheduled = []
        self._default_executor = None
        self._internal_fds = 0
        # Identifier of the thread running the event loop, or None if the
        # event loop is not running
        self._thread_id = None
        self._clock_resolution = time.get_clock_info('monotonic').resolution
        self._exception_handler = None
        self.set_debug((not sys.flags.ignore_environment
                        and bool(os.environ.get('PYTHONASYNCIODEBUG'))))
        # In debug mode, if the execution of a callback or a step of a task
        # exceed this duration in seconds, the slow callback/task is logged.
        self.slow_callback_duration = 0.1
        self._current_handle = None
        self._task_factory = None
        self._coroutine_wrapper_set = False 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:23,代码来源:base_events.py

示例3: test_monotonic

# 需要导入模块: import time [as 别名]
# 或者: from time import get_clock_info [as 别名]
def test_monotonic(self):
        # monotonic() should not go backward
        times = [time.monotonic() for n in range(100)]
        t1 = times[0]
        for t2 in times[1:]:
            self.assertGreaterEqual(t2, t1, "times=%s" % times)
            t1 = t2

        # monotonic() includes time elapsed during a sleep
        t1 = time.monotonic()
        time.sleep(0.5)
        t2 = time.monotonic()
        dt = t2 - t1
        self.assertGreater(t2, t1)
        # Issue #20101: On some Windows machines, dt may be slightly low
        self.assertTrue(0.45 <= dt <= 1.0, dt)

        # monotonic() is a monotonic but non adjustable clock
        info = time.get_clock_info('monotonic')
        self.assertTrue(info.monotonic)
        self.assertFalse(info.adjustable) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:23,代码来源:test_time.py

示例4: __init__

# 需要导入模块: import time [as 别名]
# 或者: from time import get_clock_info [as 别名]
def __init__(self):
        self._timer_cancelled_count = 0
        self._closed = False
        self._ready = collections.deque()
        self._scheduled = []
        self._default_executor = None
        self._internal_fds = 0
        # Identifier of the thread running the event loop, or None if the
        # event loop is not running
        self._thread_id = None
        self._clock_resolution = time.get_clock_info('monotonic').resolution
        self._exception_handler = None
        self._debug = (not sys.flags.ignore_environment
                       and bool(os.environ.get('PYTHONASYNCIODEBUG')))
        # In debug mode, if the execution of a callback or a step of a task
        # exceed this duration in seconds, the slow callback/task is logged.
        self.slow_callback_duration = 0.1
        self._current_handle = None 
开发者ID:hhstore,项目名称:annotated-py-projects,代码行数:20,代码来源:base_events.py

示例5: collect_time

# 需要导入模块: import time [as 别名]
# 或者: from time import get_clock_info [as 别名]
def collect_time(info_add):
    import time

    info_add('time.time', time.time())

    attributes = (
        'altzone',
        'daylight',
        'timezone',
        'tzname',
    )
    copy_attributes(info_add, time, 'time.%s', attributes)

    if hasattr(time, 'get_clock_info'):
        for clock in ('time', 'perf_counter'):
            tinfo = time.get_clock_info(clock)
            info_add('time.get_clock_info(%s)' % clock, tinfo) 
开发者ID:bkerler,项目名称:android_universal,代码行数:19,代码来源:pythoninfo.py

示例6: test_thread_time

# 需要导入模块: import time [as 别名]
# 或者: from time import get_clock_info [as 别名]
def test_thread_time(self):
        if not hasattr(time, 'thread_time'):
            if sys.platform.startswith(('linux', 'win')):
                self.fail("time.thread_time() should be available on %r"
                          % (sys.platform,))
            else:
                self.skipTest("need time.thread_time")

        # thread_time() should not include time spend during a sleep
        start = time.thread_time()
        time.sleep(0.100)
        stop = time.thread_time()
        # use 20 ms because thread_time() has usually a resolution of 15 ms
        # on Windows
        self.assertLess(stop - start, 0.020)

        info = time.get_clock_info('thread_time')
        self.assertTrue(info.monotonic)
        self.assertFalse(info.adjustable) 
开发者ID:bkerler,项目名称:android_universal,代码行数:21,代码来源:test_time.py

示例7: test_get_clock_info

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

        for name in clocks:
            if name == 'clock':
                with self.assertWarns(DeprecationWarning):
                    info = time.get_clock_info('clock')
            else:
                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:bkerler,项目名称:android_universal,代码行数:23,代码来源:test_time.py

示例8: test_time

# 需要导入模块: import time [as 别名]
# 或者: from time import get_clock_info [as 别名]
def test_time(self):
        time.time()
        info = time.get_clock_info('time')
        self.assertFalse(info.monotonic)
        self.assertTrue(info.adjustable) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:7,代码来源:test_time.py

示例9: test_clock

# 需要导入模块: import time [as 别名]
# 或者: from time import get_clock_info [as 别名]
def test_clock(self):
        time.clock()

        info = time.get_clock_info('clock')
        self.assertTrue(info.monotonic)
        self.assertFalse(info.adjustable) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:8,代码来源:test_time.py

示例10: test_process_time

# 需要导入模块: import time [as 别名]
# 或者: from time import get_clock_info [as 别名]
def test_process_time(self):
        # process_time() should not include time spend during a sleep
        start = time.process_time()
        time.sleep(0.100)
        stop = time.process_time()
        # use 20 ms because process_time() has usually a resolution of 15 ms
        # on Windows
        self.assertLess(stop - start, 0.020)

        info = time.get_clock_info('process_time')
        self.assertTrue(info.monotonic)
        self.assertFalse(info.adjustable) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:14,代码来源:test_time.py

示例11: __init__

# 需要导入模块: import time [as 别名]
# 或者: from time import get_clock_info [as 别名]
def __init__(self):
        self._timer_cancelled_count = 0
        self._closed = False
        self._stopping = False
        self._ready = collections.deque()
        self._scheduled = []
        self._default_executor = None
        self._internal_fds = 0
        # Identifier of the thread running the event loop, or None if the
        # event loop is not running
        self._thread_id = None
        self._clock_resolution = time.get_clock_info('monotonic').resolution
        self._exception_handler = None
        self.set_debug(coroutines._is_debug_mode())
        # In debug mode, if the execution of a callback or a step of a task
        # exceed this duration in seconds, the slow callback/task is logged.
        self.slow_callback_duration = 0.1
        self._current_handle = None
        self._task_factory = None
        self._coroutine_origin_tracking_enabled = False
        self._coroutine_origin_tracking_saved_depth = None

        # A weak set of all asynchronous generators that are
        # being iterated by the loop.
        self._asyncgens = weakref.WeakSet()
        # Set to True when `loop.shutdown_asyncgens` is called.
        self._asyncgens_shutdown_called = False 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:29,代码来源:base_events.py

示例12: __init__

# 需要导入模块: import time [as 别名]
# 或者: from time import get_clock_info [as 别名]
def __init__(self):
        self._timer_cancelled_count = 0
        self._closed = False
        self._stopping = False
        self._ready = collections.deque()
        self._scheduled = []
        self._default_executor = None
        self._internal_fds = 0
        # Identifier of the thread running the event loop, or None if the
        # event loop is not running
        self._thread_id = None
        self._clock_resolution = time.get_clock_info('monotonic').resolution
        self._exception_handler = None
        self.set_debug((not sys.flags.ignore_environment
                        and bool(os.environ.get('PYTHONASYNCIODEBUG'))))
        # In debug mode, if the execution of a callback or a step of a task
        # exceed this duration in seconds, the slow callback/task is logged.
        self.slow_callback_duration = 0.1
        self._current_handle = None
        self._task_factory = None
        self._coroutine_wrapper_set = False

        if hasattr(sys, 'get_asyncgen_hooks'):
            # Python >= 3.6
            # A weak set of all asynchronous generators that are
            # being iterated by the loop.
            self._asyncgens = weakref.WeakSet()
        else:
            self._asyncgens = None

        # Set to True when `loop.shutdown_asyncgens` is called.
        self._asyncgens_shutdown_called = False 
开发者ID:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:34,代码来源:base_events.py

示例13: test_clock

# 需要导入模块: import time [as 别名]
# 或者: from time import get_clock_info [as 别名]
def test_clock(self):
        with self.assertWarns(DeprecationWarning):
            time.clock()

        with self.assertWarns(DeprecationWarning):
            info = time.get_clock_info('clock')
        self.assertTrue(info.monotonic)
        self.assertFalse(info.adjustable) 
开发者ID:bkerler,项目名称:android_universal,代码行数:10,代码来源:test_time.py

示例14: timeit

# 需要导入模块: import time [as 别名]
# 或者: from time import get_clock_info [as 别名]
def timeit(measure_func, precision):
    """
    Measure the process time for measure_func with the desired precision, and
    return a tuple(mean_us, stdev_us, num_runs, num_out).
    """

    num_runs = 100  # Number of measurements to eliminate outliers
    min_rep = 5  # Minimum number of repetitions

    res_s = get_clock_info('process_time').resolution

    # Determine number of repetitions needed based on desired precision and
    # given timer resolution
    t1_s = process_time()
    measure_func()
    t2_s = process_time()
    t_s = t2_s - t1_s
    rep = max(int(float(res_s) / t_s / precision), min_rep) \
        if t_s != 0 else min_rep

    # Perform the measurement a number of times and store the results
    results = []
    for _ in six.moves.range(num_runs):
        t1_s = process_time()
        for _j in six.moves.range(rep):  # pylint: disable=unused-variable
            measure_func()
        t2_s = process_time()
        t_us = 1.0E6 * (t2_s - t1_s) / rep
        results.append(t_us)

    # Eliminate upper outliers in the results. Even though we measure process
    # time, it includes any activities done by the Python process outside of
    # our actual measured code.
    mean = statistics.mean(results)
    stdev = statistics.stdev(results)
    cleaned_results = []
    outliers = []
    for x in results:
        if x < mean + 1 * stdev:
            cleaned_results.append(x)
        else:
            outliers.append(x)
    num_out = len(outliers)

    # Calculate mean and standard deviation from cleaned results
    mean_us = statistics.mean(cleaned_results)
    stdev_us = statistics.stdev(cleaned_results)

    return mean_us, stdev_us, num_runs, num_out 
开发者ID:pywbem,项目名称:pywbem,代码行数:51,代码来源:test_perf_equality.py


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