|
@@ -258,8 +258,8 @@ class PullDataProtocol(Protocol):
|
|
|
self.recv_buffer_len = None
|
|
|
self.bytes_read = 0
|
|
|
self.protocol_helper = None
|
|
|
- self._time_of_first_byte = None
|
|
|
- self.elapsed_time = None
|
|
|
+ self.time_of_first_byte = None
|
|
|
+ self.time_of_last_byte = None
|
|
|
#
|
|
|
def _run_iteration(self):
|
|
|
if self.state is self.states.READY_TO_BEGIN:
|
|
@@ -277,12 +277,13 @@ class PullDataProtocol(Protocol):
|
|
|
#
|
|
|
if self.state is self.states.PULL_DATA:
|
|
|
if self.use_acceleration:
|
|
|
- (ret_val, elapsed_time) = accelerated_functions.pull_data(self.socket.fileno(), self.data_size, self.recv_buffer_len)
|
|
|
+ (ret_val, time_of_first_byte, time_of_last_byte) = accelerated_functions.pull_data(self.socket.fileno(), self.data_size, self.recv_buffer_len)
|
|
|
if ret_val < 0:
|
|
|
raise ProtocolException('Error while pulling data.')
|
|
|
#
|
|
|
self.bytes_read = self.data_size
|
|
|
- self.elapsed_time = elapsed_time
|
|
|
+ self.time_of_first_byte = time_of_first_byte
|
|
|
+ self.time_of_last_byte = time_of_last_byte
|
|
|
else:
|
|
|
bytes_remaining = self.data_size-self.bytes_read
|
|
|
block_size = min(self.recv_buffer_len, bytes_remaining)
|
|
@@ -294,11 +295,11 @@ class PullDataProtocol(Protocol):
|
|
|
#
|
|
|
self.bytes_read += len(data)
|
|
|
#
|
|
|
- if self.bytes_read != 0 and self._time_of_first_byte is None:
|
|
|
- self._time_of_first_byte = time.time()
|
|
|
+ if self.bytes_read != 0 and self.time_of_first_byte is None:
|
|
|
+ self.time_of_first_byte = time.time()
|
|
|
#
|
|
|
- if self.bytes_read == self.data_size and self.elapsed_time is None:
|
|
|
- self.elapsed_time = time.time()-self._time_of_first_byte
|
|
|
+ if self.bytes_read == self.data_size and self.time_of_last_byte is None:
|
|
|
+ self.time_of_last_byte = time.time()
|
|
|
#
|
|
|
#
|
|
|
if self.bytes_read == self.data_size:
|
|
@@ -321,8 +322,8 @@ class PullDataProtocol(Protocol):
|
|
|
#
|
|
|
def calc_transfer_rate(self):
|
|
|
""" Returns bytes/s. """
|
|
|
- assert self.data_size is not None and self.elapsed_time is not None
|
|
|
- return self.data_size/self.elapsed_time
|
|
|
+ assert self.data_size is not None and self.time_of_first_byte is not None and self.time_of_last_byte is not None
|
|
|
+ return self.data_size/(self.time_of_last_byte-self.time_of_first_byte)
|
|
|
#
|
|
|
#
|
|
|
class SendDataProtocol(Protocol):
|