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


Python time.time方法代码示例

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


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

示例1: draw

# 需要导入模块: from time import time [as 别名]
# 或者: from time.time import time [as 别名]
def draw(self, refresh=False, row=0, howMany=0):
        if self.dataModel.getOffset() in self.Paints:
            self.refresh = False
            self.qpix = QtGui.QPixmap(self.Paints[self.dataModel.getOffset()])
            self.drawAdditionals()
            return

        if self.refresh or refresh:
            qp = QtGui.QPainter()
            qp.begin(self.qpix)
            start = time()
            if not howMany:
                howMany = self.ROWS

            self.drawTextMode(qp, row=row, howMany=howMany)
            end = time() - start
            log.debug('draw Time ' + str(end))
            self.refresh = False
            qp.end()

        #        self.Paints[self.dataModel.getOffset()] = QtGui.QPixmap(self.qpix)
        self.drawAdditionals() 
开发者ID:amimo,项目名称:dcc,代码行数:24,代码来源:BinViewMode.py

示例2: add_timer

# 需要导入模块: from time import time [as 别名]
# 或者: from time.time import time [as 别名]
def add_timer(self, callback, when, interval, ident):
        ''' Add timer to the data structure.

        :param callback: Arbitrary callable object.
        :type callback: ``callable object``
        :param when: The first expiration time, seconds since epoch.
        :type when: ``integer``
        :param interval: Timer interval, if equals 0, one time timer, otherwise
            the timer will be periodically executed
        :type interval: ``integer``
        :param ident: (optional) Timer identity.
        :type ident:  ``integer``
        :returns: A timer object which should not be manipulated directly by
            clients. Used to delete/update the timer
        :rtype: ``solnlib.timer_queue.Timer``
        '''

        timer = Timer(callback, when, interval, ident)
        self._timers.add(timer)
        return timer 
开发者ID:remg427,项目名称:misp42splunk,代码行数:22,代码来源:timer_queue.py

示例3: get_expired_timers

# 需要导入模块: from time import time [as 别名]
# 或者: from time.time import time [as 别名]
def get_expired_timers(self):
        ''' Get a list of expired timers.

        :returns: a list of ``Timer``, empty list if there is no expired
            timers.
        :rtype: ``list``
        '''

        next_expired_time = 0
        now = time()
        expired_timers = []
        for timer in self._timers:
            if timer.when <= now:
                expired_timers.append(timer)

        if expired_timers:
            del self._timers[:len(expired_timers)]

        if self._timers:
            next_expired_time = self._timers[0].when
        return (next_expired_time, expired_timers) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:23,代码来源:timer_queue.py

示例4: draw

# 需要导入模块: from time import time [as 别名]
# 或者: from time.time import time [as 别名]
def draw(self, refresh=False, row=0, howMany=0):
        if self.dataModel.getOffset() in self.Paints:
            self.refresh = False
            self.qpix = QtGui.QPixmap(self.Paints[self.dataModel.getOffset()])
            #print 'hit'
            self.drawAdditionals()
            return

        if self.refresh or refresh:
            qp = QtGui.QPainter()
            qp.begin(self.qpix)
            #start = time()
            if not howMany:
                howMany = self.ROWS

            self.drawTextMode(qp, row=row, howMany=howMany)
            #end = time() - start
            #print 'Time ' + str(end)
            self.refresh = False
            qp.end()

#        self.Paints[self.dataModel.getOffset()] = QtGui.QPixmap(self.qpix)
        self.drawAdditionals() 
开发者ID:mtivadar,项目名称:qiew,代码行数:25,代码来源:BinViewMode.py

示例5: drip

# 需要导入模块: from time import time [as 别名]
# 或者: from time.time import time [as 别名]
def drip(self):
        """
        Let some of the bucket drain.

        The L{Bucket} drains at the rate specified by the class
        variable C{rate}.

        @returns: C{True} if the bucket is empty after this drip.
        @returntype: C{bool}
        """
        if self.parentBucket is not None:
            self.parentBucket.drip()

        if self.rate is None:
            self.content = 0
        else:
            now = time()
            deltaTime = now - self.lastDrip
            deltaTokens = deltaTime * self.rate
            self.content = max(0, self.content - deltaTokens)
            self.lastDrip = now
        return self.content == 0 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:24,代码来源:htb.py

示例6: getBucketFor

# 需要导入模块: from time import time [as 别名]
# 或者: from time.time import time [as 别名]
def getBucketFor(self, *a, **kw):
        """
        Find or create a L{Bucket} corresponding to the provided parameters.

        Any parameters are passed on to L{getBucketKey}, from them it
        decides which bucket you get.

        @returntype: L{Bucket}
        """
        if ((self.sweepInterval is not None)
            and ((time() - self.lastSweep) > self.sweepInterval)):
            self.sweep()

        if self.parentFilter:
            parentBucket = self.parentFilter.getBucketFor(self, *a, **kw)
        else:
            parentBucket = None

        key = self.getBucketKey(*a, **kw)
        bucket = self.buckets.get(key)
        if bucket is None:
            bucket = self.bucketFactory(parentBucket)
            self.buckets[key] = bucket
        return bucket 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:26,代码来源:htb.py

示例7: train

# 需要导入模块: from time import time [as 别名]
# 或者: from time.time import time [as 别名]
def train(solver_proto_path, snapshot_solver_path=None, init_weights=None, GPU_ID=0):
	"""
	Train the defined net. While we did not use this function for our final net, we used the caffe executable for multi-gpu use, this was used for prototyping
	"""

	import time
	t0 = time.time()
	caffe.set_mode_gpu()
	caffe.set_device(GPU_ID)
	solver = caffe.get_solver(solver_proto_path)
	if snapshot_solver_path is not None:
		solver.solve(snapshot_solver_path) # train from previous solverstate
	else:
		if init_weights is not None:
			solver.net.copy_from(init_weights) # for copying weights from a model without solverstate		
		solver.solve() # train form scratch

	t1 = time.time()
	print 'Total training time: ', t1-t0, ' sec'
	model_dir = "calc_" +  time.strftime("%d-%m-%Y_%I%M%S")
	moveModel(model_dir=model_dir) # move all the model files to a directory  
	print "Moved model to model/"+model_dir 
开发者ID:rpng,项目名称:calc,代码行数:24,代码来源:makeNet.py

示例8: __init__

# 需要导入模块: from time import time [as 别名]
# 或者: from time.time import time [as 别名]
def __init__(self, name, ip, **kwargs):
        self.name = str(name)
        self.ip = str(ip)
        self.throughput = kwargs.get('throughput', 0)
        self.total_throughput = kwargs.get('total_throughput', 0)
        self.max_throughput = kwargs.get('max_throughput', 0)
        self._uptime = kwargs.get('uptime', '0d 0h')
        self.cpu = kwargs.get('cpu', 0.0)
        self._usercount = kwargs.get('usercount', 0)
        # sqlite doesn't have bools
        selfcheck = kwargs.get('selfcheck', False)
        self.selfcheck = bool(selfcheck)
        # Enforce int for hearbeat (time.time() returns a float)
        heartbeat = kwargs.get('heartbeat', 0)
        self.heartbeat = int(heartbeat)
        enabled = kwargs.get('enabled', False)
        self.enabled = bool(enabled)
        is_exit = kwargs.get('is_exit', False)
        self.is_exit = bool(is_exit) 
开发者ID:benediktkr,项目名称:lokun-record,代码行数:21,代码来源:model.py

示例9: draw2

# 需要导入模块: from time import time [as 别名]
# 或者: from time.time import time [as 别名]
def draw2(self, qp, refresh=False):
        if self.refresh or refresh:
            start = time()
            self.drawTextMode(qp, howMany=self.ROWS)
            end = time() - start
            log.debug('draw2 Time ' + str(end))
            qp = QtGui.QPainter()
            qp.begin(self.qpix)

        self.drawAdditionals() 
开发者ID:amimo,项目名称:dcc,代码行数:12,代码来源:BinViewMode.py

示例10: scroll

# 需要导入模块: from time import time [as 别名]
# 或者: from time.time import time [as 别名]
def scroll(self, dx, dy, cachePix=None, pageOffset=None):
        if not cachePix:
            if self.dataModel.getOffset() in self.Paints:
                self.draw()
                return

        if dx != 0:
            if self.dataModel.inLimits((self.dataModel.getOffset() - dx)):
                self.dataModel.slide(-dx)
                self.scroll_h(dx)

        if dy != 0:
            if self.dataModel.inLimits((self.dataModel.getOffset() - dy * self.COLUMNS)):
                self.dataModel.slide(-dy * self.COLUMNS)
                # import time
                # k = time.time()
                self.scroll_v(dy, cachePix, pageOffset)
                # print time.time() - k
            else:
                if dy <= 0:
                    pass
                    # self.dataModel.slideToLastPage()
                else:
                    self.dataModel.slideToFirstPage()

                if not cachePix:
                    self.draw(refresh=True)

        if not cachePix:
            self.draw() 
开发者ID:amimo,项目名称:dcc,代码行数:32,代码来源:BinViewMode.py

示例11: _calc_sleep_time

# 需要导入模块: from time import time [as 别名]
# 或者: from time.time import time [as 别名]
def _calc_sleep_time(next_expired_time):
    if next_expired_time:
        now = time()
        if now < next_expired_time:
            sleep_time = next_expired_time - now
        else:
            sleep_time = 0.1
    else:
        sleep_time = 1
    return sleep_time 
开发者ID:remg427,项目名称:misp42splunk,代码行数:12,代码来源:timer_queue.py

示例12: testImport

# 需要导入模块: from time import time [as 别名]
# 或者: from time.time import time [as 别名]
def testImport(self):
        # 'import' dotted_as_names
        import sys
        import time, sys
        # 'from' dotted_name 'import' ('*' | '(' import_as_names ')' | import_as_names)
        from time import time
        from time import (time)
        # not testable inside a function, but already done at top of the module
        # from sys import *
        from sys import path, argv
        from sys import (path, argv)
        from sys import (path, argv,) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:14,代码来源:py3_test_grammar.py

示例13: testSelectors

# 需要导入模块: from time import time [as 别名]
# 或者: from time.time import time [as 别名]
def testSelectors(self):
        ### trailer: '(' [testlist] ')' | '[' subscript ']' | '.' NAME
        ### subscript: expr | [expr] ':' [expr]

        import sys, time
        c = sys.path[0]
        x = time.time()
        x = sys.modules['time'].time()
        a = '01234'
        c = a[0]
        c = a[-1]
        s = a[0:5]
        s = a[:5]
        s = a[0:]
        s = a[:]
        s = a[-5:]
        s = a[:-1]
        s = a[-4:-3]
        # A rough test of SF bug 1333982.  http://python.org/sf/1333982
        # The testing here is fairly incomplete.
        # Test cases should include: commas with 1 and 2 colons
        d = {}
        d[1] = 1
        d[1,] = 2
        d[1,2] = 3
        d[1,2,3] = 4
        L = list(d)
        L.sort()
        self.assertEquals(str(L), '[1, (1,), (1, 2), (1, 2, 3)]') 
开发者ID:remg427,项目名称:misp42splunk,代码行数:31,代码来源:py2_test_grammar.py

示例14: testSelectors

# 需要导入模块: from time import time [as 别名]
# 或者: from time.time import time [as 别名]
def testSelectors(self):
        ### trailer: '(' [testlist] ')' | '[' subscript ']' | '.' NAME
        ### subscript: expr | [expr] ':' [expr]

        import sys, time
        c = sys.path[0]
        x = time.time()
        x = sys.modules['time'].time()
        a = '01234'
        c = a[0]
        c = a[-1]
        s = a[0:5]
        s = a[:5]
        s = a[0:]
        s = a[:]
        s = a[-5:]
        s = a[:-1]
        s = a[-4:-3]
        # A rough test of SF bug 1333982.  http://python.org/sf/1333982
        # The testing here is fairly incomplete.
        # Test cases should include: commas with 1 and 2 colons
        d = {}
        d[1] = 1
        d[1,] = 2
        d[1,2] = 3
        d[1,2,3] = 4
        L = list(d)
        L.sort(key=lambda x: x if isinstance(x, tuple) else ())
        self.assertEquals(str(L), '[1, (1,), (1, 2), (1, 2, 3)]') 
开发者ID:remg427,项目名称:misp42splunk,代码行数:31,代码来源:py3_test_grammar.py

示例15: test_import

# 需要导入模块: from time import time [as 别名]
# 或者: from time.time import time [as 别名]
def test_import(self):
        # 'import' dotted_as_names
        import sys
        import time, sys
        # 'from' dotted_name 'import' ('*' | '(' import_as_names ')' | import_as_names)
        from time import time
        from time import (time)
        # not testable inside a function, but already done at top of the module
        # from sys import *
        from sys import path, argv
        from sys import (path, argv)
        from sys import (path, argv,) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_grammar.py


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