CpuUsage.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:supremm 作者: ubccr 项目源码 文件源码
def computeallcpus(self):
        """ overall stats for all cores on the nodes """

        ratios = numpy.empty((self._ncpumetrics, self._totalcores), numpy.double)

        coreindex = 0
        for host, last in self._last.iteritems():
            try:
                elapsed = last - self._first[host]

                if numpy.amin(numpy.sum(elapsed, 0)) < 1.0:
                    # typically happens if the job was very short and the datapoints are too close together
                    return {"error": ProcessingError.JOB_TOO_SHORT}

                coresperhost = len(last[0, :])
                ratios[:, coreindex:(coreindex+coresperhost)] = 1.0 * elapsed / numpy.sum(elapsed, 0)
                coreindex += coresperhost
            except ValueError:
                # typically happens if the linux pmda crashes during the job
                return {"error": ProcessingError.INSUFFICIENT_DATA}

        results = {}
        for i, name in enumerate(self._outnames):
            results[name] = calculate_stats(ratios[i, :])

        results['all'] = {"cnt": self._totalcores}

        return results
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号