def _MeasureReadTime(self, count):
    mock_time = self._mock_timer.time() + 1
    payload = ','.join(['{}'] * 5000)
    self._inspector_socket.AddAsyncResponse('IO.read', {'data': '[' + payload},
                                            mock_time)
    startClock = time.clock()

    done = {'done': False}
    def mark_done(data):
      del data  # unused
      done['done'] = True

    reader = _DevToolsStreamReader(self._inspector_socket, 'dummy')
    reader.Read(mark_done)
    while not done['done']:
      mock_time += 1
      if count > 0:
        self._inspector_socket.AddAsyncResponse('IO.read', {'data': payload},
            mock_time)
      elif count == 0:
        self._inspector_socket.AddAsyncResponse('IO.read',
            {'data': payload + ']', 'eof': True}, mock_time)
      count -= 1
      self._inspector_socket.DispatchNotifications(10)
    return time.clock() - startClock
Пример #2
0
    def _MeasureReadTime(self, count):
        mock_time = self._mock_timer.time() + 1
        payload = ','.join(['{}'] * 5000)
        self._inspector_socket.AddAsyncResponse('IO.read',
                                                {'data': '[' + payload},
                                                mock_time)
        startClock = time.clock()

        done = {'done': False}

        def mark_done(data):
            done['done'] = True

        reader = _DevToolsStreamReader(self._inspector_socket, 'dummy')
        reader.Read(mark_done)
        while not done['done']:
            mock_time += 1
            if count > 0:
                self._inspector_socket.AddAsyncResponse(
                    'IO.read', {'data': payload}, mock_time)
            elif count == 0:
                self._inspector_socket.AddAsyncResponse(
                    'IO.read', {
                        'data': payload + ']',
                        'eof': True
                    }, mock_time)
            count -= 1
            self._inspector_socket.DispatchNotifications(10)
        return time.clock() - startClock
Пример #3
0
  def _MeasureReadTime(self, count):
    fake_time = self._fake_timer.time() + 1
    payload = ','.join(['{}'] * 5000)
    self._inspector_socket.AddAsyncResponse('IO.read', {'data': '[' + payload},
                                            fake_time)
    start_clock = timeit.default_timer()

    done = {'done': False}
    def MarkDone():
      done['done'] = True

    with open(os.devnull, 'wb') as trace_handle:
      reader = tracing_backend._DevToolsStreamReader(
          self._inspector_socket, 'dummy', trace_handle)
      reader.Read(MarkDone)
      while not done['done']:
        fake_time += 1
        if count > 0:
          self._inspector_socket.AddAsyncResponse(
              'IO.read', {'data': payload},
              fake_time)
        elif count == 0:
          self._inspector_socket.AddAsyncResponse(
              'IO.read',
              {'data': payload + ']', 'eof': True}, fake_time)
        count -= 1
        self._inspector_socket.DispatchNotifications(10)
    return timeit.default_timer() - start_clock