本文整理匯總了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()
示例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
示例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)
示例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()
示例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
示例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
示例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
示例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)
示例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()
示例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()
示例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
示例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,)
示例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)]')
示例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)]')
示例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,)