當前位置: 首頁>>代碼示例>>Python>>正文


Python time.time方法代碼示例

本文整理匯總了Python中time.time方法的典型用法代碼示例。如果您正苦於以下問題:Python time.time方法的具體用法?Python time.time怎麽用?Python time.time使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在time的用法示例。


在下文中一共展示了time.time方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import time [as 別名]
# 或者: from time import time [as 別名]
def __init__(self, name=""):
        self.barsToProgress = {}

        self.t0 = time.time()
        self.timeRemaining = "--"
        self.status = "+"
        self.name = name
        self.lastRedraw = time.time()
        self.isatty = sys.stdout.isatty()

        try:
            self.handleResize(None,None)
            signal.signal(signal.SIGWINCH, self.handleResize)
            self.signal_set = True
        except:
            self.term_width = 79 
開發者ID:svviz,項目名稱:svviz,代碼行數:18,代碼來源:multiprocessor.py

示例2: moveForward

# 需要導入模塊: import time [as 別名]
# 或者: from time import time [as 別名]
def moveForward(motion_service):
    X = 1  # forward
    Y = 0.0
    Theta = 0.0

    print "Movement Starting"
    t0= time.time()

    # Blocking call
    possible = motion_service.moveTo(X, Y, Theta)

    t1 = time.time()

    timeDiff = t1 -t0
    timeDiff *= 1000

    if not possible:
        return -1

    # if not possible:
    #     print "Interruption case Time : ",timeDiff
    # else:
    #     print "Journey over Time : ",timeDiff

    return timeDiff 
開發者ID:maverickjoy,項目名稱:pepper-robot-programming,代碼行數:27,代碼來源:robot_velocity_caliberation.py

示例3: start

# 需要導入模塊: import time [as 別名]
# 或者: from time import time [as 別名]
def start(self):       
        
        ####################
        start = time.time()
        ####################         

        self._create_folder_structure()
        self._clear_previous_executions()        
        self._add_ipynb()  
        self._get_flow_results()
        self._add_network_context()
        self._add_geo_localization()
        self._add_reputation()        
        self._create_flow_scores()
        self._get_oa_details()
        self._ingest_summary()

        ##################
        end = time.time()
        print(end - start)
        ################## 
開發者ID:apache,項目名稱:incubator-spot,代碼行數:23,代碼來源:flow_oa.py

示例4: start

# 需要導入模塊: import time [as 別名]
# 或者: from time import time [as 別名]
def start(self):

        ####################
        start = time.time()
        ####################

        self._create_folder_structure()
        self._clear_previous_executions()   
        self._add_ipynb()
        self._get_proxy_results()
        self._add_reputation() 
        self._add_iana()
        self._add_network_context() 
        self._create_proxy_scores_csv()
        self._get_oa_details()
        self._ingest_summary()


        ##################
        end = time.time()
        print(end - start)
        ################## 
開發者ID:apache,項目名稱:incubator-spot,代碼行數:24,代碼來源:proxy_oa.py

示例5: start

# 需要導入模塊: import time [as 別名]
# 或者: from time import time [as 別名]
def start(self):

        ####################
        start = time.time()
        ####################

        self._clear_previous_executions()
        self._create_folder_structure()
        self._add_ipynb()
        self._get_dns_results()
        self._add_tld_column()
        self._add_reputation()
        self._add_hh_column()
        self._add_iana()
        self._add_network_context()
        self._create_dns_scores()
        self._get_oa_details()
        self._ingest_summary()

        ##################
        end = time.time()
        print(end - start)
        ################## 
開發者ID:apache,項目名稱:incubator-spot,代碼行數:25,代碼來源:dns_oa.py

示例6: _calc_it_per_sec

# 需要導入模塊: import time [as 別名]
# 或者: from time import time [as 別名]
def _calc_it_per_sec(self):
        now = time.time()
        
        if not self.last_it:
            self.last_it.append(now)
        else:
            self.last_it.append(now)
            if len(self.last_it) >= 100:
                self.last_it = self.last_it[-100:]

            # smooth it/sec
            intervals = list(map(lambda t: t[1] - t[0], zip(self.last_it[:-1], self.last_it[1:])))
            delta = sum(intervals) / len(intervals)
            if delta != 0.:
                it_per_sec = 1.0 / delta
                if it_per_sec > 1_000_00:
                    self.it_per_sec = "{}M".format(int(it_per_sec/1_000_000))
                elif it_per_sec > 1_000:
                    self.it_per_sec = "{}K".format(int(it_per_sec/1_000))
                else:
                    self.it_per_sec = "{:.2f}".format(it_per_sec)
                # 6 characters so the progress bar is the same size
                self.it_per_sec = self.it_per_sec.rjust(6)
                # self.last_it = now 
開發者ID:mme,項目名稱:vergeml,代碼行數:26,代碼來源:display.py

示例7: _startImageCapturingAtGraphNode

# 需要導入模塊: import time [as 別名]
# 或者: from time import time [as 別名]
def _startImageCapturingAtGraphNode(self):
        amntY = 0.3
        xdir = [-0.5, 0, 0.5]
        cameraId = 0

        for idx,amntX in enumerate(xdir):
            self._moveHead(amntX, amntY)
            time.sleep(0.1)
            self._checkIfAsthamaInEnvironment(cameraId)
            if self.pumpFound :
                # Setting rotation angle of body towards head
                theta = 0
                if idx == 0: # LEFT
                    theta = math.radians(-45)
                if idx == 2: # RIGHT
                    theta = math.radians(45)
                self.pumpAngleRotation = theta

                return "KILLING GRAPH SEARCH : PUMP FOUND"

        self._moveHead(0, 0) # Bringing to initial view

        return 
開發者ID:maverickjoy,項目名稱:pepper-robot-programming,代碼行數:25,代碼來源:asthama_search.py

示例8: _capture2dImage

# 需要導入模塊: import time [as 別名]
# 或者: from time import time [as 別名]
def _capture2dImage(self, cameraId):
        # Capture Image in RGB

        # WARNING : The same Name could be used only six time.
        strName = "capture2DImage_{}".format(random.randint(1,10000000000))

        clientRGB = self.video_service.subscribeCamera(strName, cameraId, AL_kVGA, 11, 10)
        imageRGB = self.video_service.getImageRemote(clientRGB)

        imageWidth   = imageRGB[0]
        imageHeight  = imageRGB[1]
        array        = imageRGB[6]
        image_string = str(bytearray(array))

        # Create a PIL Image from our pixel array.
        im = Image.frombytes("RGB", (imageWidth, imageHeight), image_string)

        # Save the image.
        image_name_2d = "images/img2d-" + str(self.imageNo2d) + ".png"
        im.save(image_name_2d, "PNG") # Stored in images folder in the pwd, if not present then create one
        self.imageNo2d += 1
        im.show()

        return 
開發者ID:maverickjoy,項目名稱:pepper-robot-programming,代碼行數:26,代碼來源:asthama_search.py

示例9: _capture3dImage

# 需要導入模塊: import time [as 別名]
# 或者: from time import time [as 別名]
def _capture3dImage(self):
        # Depth Image in RGB

        # WARNING : The same Name could be used only six time.
        strName = "capture3dImage_{}".format(random.randint(1,10000000000))


        clientRGB = self.video_service.subscribeCamera(strName, AL_kDepthCamera, AL_kQVGA, 11, 10)
        imageRGB = self.video_service.getImageRemote(clientRGB)

        imageWidth  = imageRGB[0]
        imageHeight = imageRGB[1]
        array       = imageRGB[6]
        image_string = str(bytearray(array))

        # Create a PIL Image from our pixel array.
        im = Image.frombytes("RGB", (imageWidth, imageHeight), image_string)
        # Save the image.
        image_name_3d = "images/img3d-" + str(self.imageNo3d) + ".png"
        im.save(image_name_3d, "PNG") # Stored in images folder in the pwd, if not present then create one
        self.imageNo3d += 1
        im.show()

        return 
開發者ID:maverickjoy,項目名稱:pepper-robot-programming,代碼行數:26,代碼來源:asthama_search.py

示例10: wait_for_port

# 需要導入模塊: import time [as 別名]
# 或者: from time import time [as 別名]
def wait_for_port(host, port, timeout=600, print_progress=True):
    if print_progress:
        sys.stderr.write("Waiting for {}:{}...".format(host, port))
        sys.stderr.flush()
    start_time = time.time()
    while True:
        try:
            socket.socket().connect((host, port))
            if print_progress:
                sys.stderr.write(GREEN("OK") + "\n")
            return
        except Exception:
            time.sleep(1)
            if print_progress:
                sys.stderr.write(".")
                sys.stderr.flush()
            if time.time() - start_time > timeout:
                raise 
開發者ID:kislyuk,項目名稱:aegea,代碼行數:20,代碼來源:__init__.py

示例11: __new__

# 需要導入模塊: import time [as 別名]
# 或者: from time import time [as 別名]
def __new__(cls, t, snap=0):
        if isinstance(t, (str, bytes)) and t.isdigit():
            t = int(t)
        if not isinstance(t, (str, bytes)):
            from dateutil.tz import tzutc
            return datetime.fromtimestamp(t // 1000, tz=tzutc())
        try:
            units = ["weeks", "days", "hours", "minutes", "seconds"]
            diffs = {u: float(t[:-1]) for u in units if u.startswith(t[-1])}
            if len(diffs) == 1:
                # Snap > 0 governs the rounding of units (hours, minutes and seconds) to 0 to improve cache performance
                snap_units = {u.rstrip("s"): 0 for u in units[units.index(list(diffs)[0]) + snap:]} if snap else {}
                snap_units.pop("day", None)
                snap_units.update(microsecond=0)
                ts = datetime.now().replace(**snap_units) + relativedelta(**diffs)
                cls._precision[ts] = snap_units
                return ts
            return dateutil_parse(t)
        except (ValueError, OverflowError, AssertionError):
            raise ValueError('Could not parse "{}" as a timestamp or time delta'.format(t)) 
開發者ID:kislyuk,項目名稱:aegea,代碼行數:22,代碼來源:__init__.py

示例12: main

# 需要導入模塊: import time [as 別名]
# 或者: from time import time [as 別名]
def main(_):
  """Runs `text_utils.simplify_nq_example` over all shards of a split.

  Prints simplified examples to a single gzipped file in the same directory
  as the input shards.
  """
  split = os.path.basename(FLAGS.data_dir)
  outpath = os.path.join(FLAGS.data_dir,
                         "simplified-nq-{}.jsonl.gz".format(split))
  with gzip.open(outpath, "wb") as fout:
    num_processed = 0
    start = time.time()
    for inpath in glob.glob(os.path.join(FLAGS.data_dir, "nq-*-??.jsonl.gz")):
      print("Processing {}".format(inpath))
      with gzip.open(inpath, "rb") as fin:
        for l in fin:
          utf8_in = l.decode("utf8", "strict")
          utf8_out = json.dumps(
              text_utils.simplify_nq_example(json.loads(utf8_in))) + u"\n"
          fout.write(utf8_out.encode("utf8"))
          num_processed += 1
          if not num_processed % 100:
            print("Processed {} examples in {}.".format(num_processed,
                                                        time.time() - start)) 
開發者ID:google-research-datasets,項目名稱:natural-questions,代碼行數:26,代碼來源:simplify_nq_data.py

示例13: __on_event

# 需要導入模塊: import time [as 別名]
# 或者: from time import time [as 別名]
def __on_event(self):
        event = self._queue.get()
        if event.type == Events.SCAN_ERROR:
            self.__on_scan_error(event.data)
        elif event.type == Events.SCAN_DATA:
            self.__on_scan_data(event.data)
        elif event.type == Events.SERVER_ERROR:
            self.__on_server_error(event.data)
        elif event.type == Events.GPS_ERROR:
            self.__std_err(event.data['msg'])
            self.__restart_gps()
        elif event.type == Events.GPS_WARN:
            self.__std_err(event.data['msg'])
        elif event.type == Events.GPS_TIMEOUT:
            self.__std_err(event.data['msg'])
            self.__restart_gps()
        elif event.type == Events.GPS_LOC:
            self._location = event.data['loc']
        elif event.type == Events.PUSH_ERROR:
            if not self._warnedPush:
                self._warnedPush = True
                self.__std_err('Push failed:\n\t' + event.data['msg'])
        else:
            time.sleep(0.01) 
開發者ID:EarToEarOak,項目名稱:RF-Monitor,代碼行數:26,代碼來源:cli.py

示例14: __on_rec

# 需要導入模塊: import time [as 別名]
# 或者: from time import time [as 別名]
def __on_rec(self, recording):
        timestamp = time.time()
        for monitor in self._monitors:
            if not recording:
                monitor.set_level(None, timestamp, None)
            monitor.set_recording(recording, timestamp)

        if recording:
            self.__on_start()
        else:
            while self._push.hasFailed():
                resp = wx.MessageBox('Web push has failed, retry?', 'Warning',
                                     wx.OK | wx.CANCEL | wx.ICON_WARNING)
                if resp == wx.OK:
                    busy = wx.BusyInfo('Pushing...', self)
                    self._push.send_failed(self._settings.get_push_uri())
                    del busy
                else:
                    self._push.clear_failed()

        self._warnedPush = False
        self.__set_timeline() 
開發者ID:EarToEarOak,項目名稱:RF-Monitor,代碼行數:24,代碼來源:gui.py

示例15: current_milli_time

# 需要導入模塊: import time [as 別名]
# 或者: from time import time [as 別名]
def current_milli_time():
    return int(round(time.time() * 1000)) 
開發者ID:pimoroni,項目名稱:unicorn-hat-hd,代碼行數:4,代碼來源:demo.py


注:本文中的time.time方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。