Returns total BMDS execution time, in seconds.
349239
def execution_duration(self):
        
        duration = None
        if self.execution_start and self.execution_end:
            delta = self.execution_end - self.execution_start
            duration = delta.total_seconds()
        return duration
58054
def _get_centroid_time(self, time_diff):
        
        source_time = datetime.datetime.combine(self.date, self.time)
        second_diff = floor(fabs(time_diff))
        microsecond_diff = int(1000. * (time_diff - second_diff))
        if time_diff < 0.:
            source_time = source_time - datetime.timedelta(
                seconds=int(second_diff), microseconds=microsecond_diff)
        else:
            source_time = source_time + datetime.timedelta(
                seconds=int(second_diff), microseconds=microsecond_diff)
        self.time = source_time.time()
        self.date = source_time.date()
813034
def total_self_time(self):
        '''
        
        '''
        self_time = self.self_time
        for child in self.children:
            if isinstance(child, SelfTimeFrame):
                self_time += child.self_time
        return self_time
25042
def total_duration(self):
        
        durations = [result.duration for result in self.data]
        return sum(durations)
276795
def timedelta_total_minutes(td, strict=False):
    
    minutes, seconds = divmod(td.days * 24 * 3600 + td.seconds, 60)
    if seconds or td.microseconds:
        if strict:
            raise ValueError(
                "%r is not an integral multiple of 60 seconds", td)
        if seconds > 30 or (seconds == 30 and td.microseconds > 0):
            minutes += 1
    return minutes
1245183
def num_time_steps(self):
    """"""

    num_time_steps = sum(t.num_time_steps for t in self.trajectories)
    return num_time_steps + self.num_completed_time_steps
1196510
def time_to_seconds(t):
    
    l = list(map(int, t.split(':')))
    return sum(n * sec for n, sec in zip(l[::-1], (1, 60, 3600)))
316203
def _timedelta_to_seconds(td):
        
        if isinstance(td, numbers.Real):
            td = datetime.timedelta(seconds=td)
        return td.total_seconds()
59686
def get_runtime(self):
        """"""
        if self.start is None: return None

        if self.end is None:
            delta = datetime.datetime.now() - self.start
        else:
            delta = self.end - self.start

        return MyTimedelta.as_timedelta(delta)
812685
def execute_job(self, obj):
        

        # get executable path
        exe = session.BMDS.get_model(obj["bmds_version"], obj["model_name"]).get_exe_path()

        # write dfile
        dfile = self.tempfiles.get_tempfile(prefix="bmds-dfile-", suffix=".(d)")
        with open(dfile, "w") as f:
            f.write(obj["dfile"])

        outfile = self.get_outfile(dfile, obj["model_name"])
        oo2 = outfile.replace(".out", ".002")

        proc = subprocess.Popen([exe, dfile], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

        output = None
        stdout = ""
        stderr = ""

        try:
            stdout, stderr = proc.communicate(timeout=settings.BMDS_MODEL_TIMEOUT_SECONDS)

            if os.path.exists(outfile):
                with open(outfile, "r") as f:
                    output = f.read()

            status = RunStatus.SUCCESS.value
            stdout = stdout.decode().strip()
            stderr = stderr.decode().strip()

        except subprocess.TimeoutExpired:
            proc.kill()
            status = RunStatus.FAILURE.value
            stdout, stderr = proc.communicate()

        finally:
            if os.path.exists(outfile):
                self.tempfiles.append(outfile)
            if os.path.exists(oo2):
                self.tempfiles.append(oo2)

        self.tempfiles.cleanup()

        return dict(status=status, output=output, stdout=stdout, stderr=stderr)
1005085
async def async_get_bytes_total(self, use_cache=True):
        """"""
        now = datetime.utcnow()
        if use_cache and self._trans_cache_timer and self._cache_time > \
                (now - self._trans_cache_timer).total_seconds():
            return self._transfer_rates_cache

        rx = await self.async_get_rx()
        tx = await self.async_get_tx()
        return rx, tx
983548
public double getDurationMs() {
        double durationMs = 0;
        for (Duration duration : durations) {
            if (duration.taskFinished()) {
                durationMs += duration.getDurationMS();
            }
        }
        return durationMs;
    }
681636
public long getCumulativeCpuTime() {
    if (JIFFY_LENGTH_IN_MILLIS < 0) {
      return 0;
    }
    long incJiffies = 0;
    for (ProcessInfo p : processTree.values()) {
      if (p != null) {
        incJiffies += p.dtime;
      }
    }
    if (incJiffies * JIFFY_LENGTH_IN_MILLIS < Integer.MAX_VALUE) {
      // Ignore the values that are ridiculous
      cpuTime += incJiffies * JIFFY_LENGTH_IN_MILLIS;
    }

    return cpuTime;
  }
583871
def get_cpu_timings(self):
        
        timings = {}
        with open('/proc/stat', 'r') as file_obj:
            for line in file_obj:
                if 'cpu' in line:
                    line = line.strip().split()
                    timings[line[0]] = [int(x) for x in line[1:]]

        return timings
767471
def modification_time(self):
    """"""
    timestamp = self._fsapfs_file_entry.get_modification_time_as_integer()
    return dfdatetime_apfs_time.APFSTime(timestamp=timestamp)
479845
public Integer getTotalLagInMilliSeconds()
    {
        final String totalLagStripped = stripUnit(this.totalLag);
        return totalLagStripped == null ? null : Integer.valueOf(totalLagStripped);
    }
6560
private static double getDurationInSecs(
      ViewData.AggregationWindowData.CumulativeData cumulativeData) {
    return toDoubleSeconds(cumulativeData.getEnd().subtractTimestamp(cumulativeData.getStart()));
  }