Exemplo n.º 1
0
 def timedelta(self, start, end, start_key=min, end_key=max):
     """compute the difference between two sets of timestamps
     
     The default behavior is to use the earliest of the first
     and the latest of the second list, but this can be changed
     by passing a different
     
     Parameters
     ----------
     
     start : one or more datetime objects (e.g. ar.submitted)
     end : one or more datetime objects (e.g. ar.received)
     start_key : callable
         Function to call on `start` to extract the relevant
         entry [default: min]
     end_key : callable
         Function to call on `end` to extract the relevant
         entry [default: max]
     
     Returns
     -------
     
     dt : float
         The time elapsed (in seconds) between the two selected timestamps.
     """
     if not isinstance(start, datetime):
         # handle single_result AsyncResults, where ar.stamp is single object,
         # not a list
         start = start_key(start)
     if not isinstance(end, datetime):
         # handle single_result AsyncResults, where ar.stamp is single object,
         # not a list
         end = end_key(end)
     return compare_datetimes(end, start).total_seconds()
Exemplo n.º 2
0
 def timedelta(self, start, end, start_key=min, end_key=max):
     """compute the difference between two sets of timestamps
     
     The default behavior is to use the earliest of the first
     and the latest of the second list, but this can be changed
     by passing a different
     
     Parameters
     ----------
     
     start : one or more datetime objects (e.g. ar.submitted)
     end : one or more datetime objects (e.g. ar.received)
     start_key : callable
         Function to call on `start` to extract the relevant
         entry [default: min]
     end_key : callable
         Function to call on `end` to extract the relevant
         entry [default: max]
     
     Returns
     -------
     
     dt : float
         The time elapsed (in seconds) between the two selected timestamps.
     """
     if not isinstance(start, datetime):
         # handle single_result AsyncResults, where ar.stamp is single object,
         # not a list
         start = start_key(start)
     if not isinstance(end, datetime):
         # handle single_result AsyncResults, where ar.stamp is single object,
         # not a list
         end = end_key(end)
     return compare_datetimes(end, start).total_seconds()
Exemplo n.º 3
0
 def serial_time(self):
     """serial computation time of a parallel calculation
     
     Computed as the sum of (completed-started) of each task
     """
     t = 0
     for md in self._metadata:
         t += compare_datetimes(md['completed'], md['started']).total_seconds()
     return t
Exemplo n.º 4
0
 def serial_time(self):
     """serial computation time of a parallel calculation
     
     Computed as the sum of (completed-started) of each task
     """
     t = 0
     for md in self._metadata:
         t += compare_datetimes(md['completed'], md['started']).total_seconds()
     return t
Exemplo n.º 5
0
 def elapsed(self):
     """elapsed time since initial submission"""
     if self.ready():
         return self.wall_time
     
     now = submitted = utcnow()
     for msg_id in self.msg_ids:
         if msg_id in self._client.metadata:
             stamp = self._client.metadata[msg_id]['submitted']
             if stamp and stamp < submitted:
                 submitted = stamp
     return compare_datetimes(now, submitted).total_seconds()
Exemplo n.º 6
0
    def elapsed(self):
        """elapsed time since initial submission"""
        if self.ready():
            return self.wall_time

        now = submitted = utcnow()
        for msg_id in self.msg_ids:
            if msg_id in self._client.metadata:
                stamp = self._client.metadata[msg_id]['submitted']
                if stamp and stamp < submitted:
                    submitted = stamp
        return compare_datetimes(now, submitted).total_seconds()
Exemplo n.º 7
0
    def elapsed(self):
        """elapsed time since initial submission"""
        if self.ready():
            return self.wall_time

        now = submitted = utcnow()
        self._parse_metadata_dates()
        for md in self._metadata:
            stamp = md["submitted"]
            if stamp and stamp < submitted:
                submitted = stamp
        return compare_datetimes(now, submitted).total_seconds()