当前位置: 首页>>代码示例>>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;未经允许,请勿转载。