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


Python time.clock_gettime方法代码示例

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


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

示例1: test_time_ns_type

# 需要导入模块: import time [as 别名]
# 或者: from time import clock_gettime [as 别名]
def test_time_ns_type(self):
        def check_ns(sec, ns):
            self.assertIsInstance(ns, int)

            sec_ns = int(sec * 1e9)
            # tolerate a difference of 50 ms
            self.assertLess((sec_ns - ns), 50 ** 6, (sec, ns))

        check_ns(time.time(),
                 time.time_ns())
        check_ns(time.monotonic(),
                 time.monotonic_ns())
        check_ns(time.perf_counter(),
                 time.perf_counter_ns())
        check_ns(time.process_time(),
                 time.process_time_ns())

        if hasattr(time, 'thread_time'):
            check_ns(time.thread_time(),
                     time.thread_time_ns())

        if hasattr(time, 'clock_gettime'):
            check_ns(time.clock_gettime(time.CLOCK_REALTIME),
                     time.clock_gettime_ns(time.CLOCK_REALTIME)) 
开发者ID:bkerler,项目名称:android_universal,代码行数:26,代码来源:test_time.py

示例2: thread_clock

# 需要导入模块: import time [as 别名]
# 或者: from time import clock_gettime [as 别名]
def thread_clock():
        return time.clock_gettime(time.CLOCK_THREAD_CPUTIME_ID)


#: Does nothing.  It allows any arguments. 
开发者ID:what-studio,项目名称:profiling,代码行数:7,代码来源:utils.py

示例3: __enter__

# 需要导入模块: import time [as 别名]
# 或者: from time import clock_gettime [as 别名]
def __enter__(self):
        _log.debug('>>> %s', self.section)
        self.start = time.clock_gettime(time.CLOCK_MONOTONIC)
        return self 
开发者ID:flyingcircusio,项目名称:vulnix,代码行数:6,代码来源:utils.py

示例4: __exit__

# 需要导入模块: import time [as 别名]
# 或者: from time import clock_gettime [as 别名]
def __exit__(self, *exc):
        self.end = time.clock_gettime(time.CLOCK_MONOTONIC)
        self.interval = self.end - self.start
        _log.debug('<<< %s %.2fs', self.section, self.interval)
        return False  # re-raise 
开发者ID:flyingcircusio,项目名称:vulnix,代码行数:7,代码来源:utils.py

示例5: test_clock_realtime

# 需要导入模块: import time [as 别名]
# 或者: from time import clock_gettime [as 别名]
def test_clock_realtime(self):
        time.clock_gettime(time.CLOCK_REALTIME) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:4,代码来源:test_time.py

示例6: test_clock_monotonic

# 需要导入模块: import time [as 别名]
# 或者: from time import clock_gettime [as 别名]
def test_clock_monotonic(self):
        a = time.clock_gettime(time.CLOCK_MONOTONIC)
        b = time.clock_gettime(time.CLOCK_MONOTONIC)
        self.assertLessEqual(a, b) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:6,代码来源:test_time.py

示例7: test_clock_settime

# 需要导入模块: import time [as 别名]
# 或者: from time import clock_gettime [as 别名]
def test_clock_settime(self):
        t = time.clock_gettime(time.CLOCK_REALTIME)
        try:
            time.clock_settime(time.CLOCK_REALTIME, t)
        except PermissionError:
            pass

        if hasattr(time, 'CLOCK_MONOTONIC'):
            self.assertRaises(OSError,
                              time.clock_settime, time.CLOCK_MONOTONIC, 0) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:12,代码来源:test_time.py

示例8: test_monotonic_settime

# 需要导入模块: import time [as 别名]
# 或者: from time import clock_gettime [as 别名]
def test_monotonic_settime(self):
        t1 = time.monotonic()
        realtime = time.clock_gettime(time.CLOCK_REALTIME)
        # jump backward with an offset of 1 hour
        try:
            time.clock_settime(time.CLOCK_REALTIME, realtime - 3600)
        except PermissionError as err:
            self.skipTest(err)
        t2 = time.monotonic()
        time.clock_settime(time.CLOCK_REALTIME, realtime)
        # monotonic must not be affected by system clock updates
        self.assertGreaterEqual(t2, t1) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:14,代码来源:test_time.py

示例9: _set_real_base

# 需要导入模块: import time [as 别名]
# 或者: from time import clock_gettime [as 别名]
def _set_real_base(self, metaconvert):
        self._real_base = int(
            time.clock_gettime(time.CLOCK_REALTIME) *
            FFmpegPipeline.SECONDS_TO_NANOSECONDS)

        if ("tags" not in self.request):
            self.request["tags"] = {}

        self.request["tags"]["real_base"] = self._real_base

        properties = self._video_filter_map[metaconvert].properties
        properties["tags"] = "\'{}\'".format(
            json.dumps(self.request["tags"]).replace(':', r'\:')) 
开发者ID:intel,项目名称:video-analytics-serving,代码行数:15,代码来源:ffmpeg_pipeline.py

示例10: monotonic

# 需要导入模块: import time [as 别名]
# 或者: from time import clock_gettime [as 别名]
def monotonic():
                """Monotonic clock, cannot go backward."""
                ts = timespec()
                if clock_gettime(CLOCK_MONOTONIC, ctypes.pointer(ts)):
                    errno = ctypes.get_errno()
                    raise OSError(errno, os.strerror(errno))
                return ts.tv_sec + ts.tv_nsec / 1.0e9

        # Perform a sanity-check. 
开发者ID:bakwc,项目名称:PySyncObj,代码行数:11,代码来源:monotonic.py

示例11: clock

# 需要导入模块: import time [as 别名]
# 或者: from time import clock_gettime [as 别名]
def clock():
        return time.clock_gettime(time.CLOCK_THREAD_CPUTIME_ID) 
开发者ID:supermihi,项目名称:lpdec,代码行数:4,代码来源:utils.py

示例12: set_mode

# 需要导入模块: import time [as 别名]
# 或者: from time import clock_gettime [as 别名]
def set_mode(self, mode=MODE_SLEEP, t_sb=t_sb_1000):
        # Writes ctrl_meas register with current temperature and pressure oversampling settings
        # Only changes the mode
        # If normal mode selected also sets the standby time in config register

        # Set class variables
        self.mode = mode
        self.t_sb = t_sb

        # If no measurements are enabled there is no point going into measurement
        if self.osrs_t + self.osrs_p + self.osrs_h == 0:
            print("No measurement enabled!\nSee set_oversampling()-function to enable measurement.")
            return 0

        try:
            # If normal mode set also t_sb(standby time)
            if self.mode == self.MODE_NORMAL:
                # Write normal mode standby time t_sb to config register
                self.__config(t_sb, self.filter, self.spi3w_en)
                # Write mode to ctr_meas register
                self.__ctrl_meas(self.osrs_t, self.osrs_p, self.mode)
            # Otherwise just change the mode in ctrl_meas register
            else:
                self.__ctrl_meas(self.osrs_t, self.osrs_p, self.mode)

            self.last_meas = clock_gettime(CLOCK_REALTIME)
            # Everything went well return 1
            return 1
        except Exception as e:
            # e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
            return 0

    #########################################################################
    # Set oversampling/enable measurement. OVRS_x0 disables the measurement #
    ######################################################################### 
开发者ID:Seeed-Studio,项目名称:grove.py,代码行数:38,代码来源:__init__.py

示例13: test_clock_realtime

# 需要导入模块: import time [as 别名]
# 或者: from time import clock_gettime [as 别名]
def test_clock_realtime(self):
        t = time.clock_gettime(time.CLOCK_REALTIME)
        self.assertIsInstance(t, float) 
开发者ID:bkerler,项目名称:android_universal,代码行数:5,代码来源:test_time.py

示例14: test_pthread_getcpuclockid

# 需要导入模块: import time [as 别名]
# 或者: from time import clock_gettime [as 别名]
def test_pthread_getcpuclockid(self):
        clk_id = time.pthread_getcpuclockid(threading.get_ident())
        self.assertTrue(type(clk_id) is int)
        self.assertNotEqual(clk_id, time.CLOCK_THREAD_CPUTIME_ID)
        t1 = time.clock_gettime(clk_id)
        t2 = time.clock_gettime(clk_id)
        self.assertLessEqual(t1, t2) 
开发者ID:bkerler,项目名称:android_universal,代码行数:9,代码来源:test_time.py


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