Skip to content

Commit

Permalink
uplaoding
Browse files Browse the repository at this point in the history
  • Loading branch information
oguzhaninan committed Feb 28, 2018
1 parent e48c4f2 commit 728c65c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
14 changes: 8 additions & 6 deletions stacer-core/Info/cpu_info.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#include "cpu_info.h"

CpuInfo::CpuInfo()
{ }

quint8 CpuInfo::getCpuCoreCount() const
{
static quint8 count = 0;

if (! count)
{
if (! count) {
QStringList cpuinfo = FileUtil::readListFromFile(PROC_CPUINFO);

if (! cpuinfo.isEmpty())
Expand All @@ -18,6 +14,12 @@ quint8 CpuInfo::getCpuCoreCount() const
return count;
}

QList<int> CpuInfo::getLoadAvgs()
{
QStringList avgs = FileUtil::readStringFromFile(PROC_LOADAVG).split(QRegExp("\\s+"));

}

QList<int> CpuInfo::getCpuPercents() const
{
QList<double> cpuTimes;
Expand Down Expand Up @@ -79,7 +81,7 @@ int CpuInfo::getCpuPercent(const QList<double> &cpuTimes, const int &processor)
double total = 0.0;
for (const double &t : cpuTimes) total += t; // get total time

double idle_delta = idle - l_idles[processor];
double idle_delta = idle - l_idles[processor];
double total_delta = total - l_totals[processor];

if (total_delta)
Expand Down
4 changes: 2 additions & 2 deletions stacer-core/Info/cpu_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
#include "Utils/file_util.h"

#define PROC_CPUINFO "/proc/cpuinfo"
#define PROC_LOADAVG "/proc/loadavg"
#define PROC_STAT "/proc/stat"

#include "stacer-core_global.h"

class STACERCORESHARED_EXPORT CpuInfo
{
public:
CpuInfo();

quint8 getCpuCoreCount() const;
QList<int> getCpuPercents() const;
QList<int> getLoadAvgs();

private:
int getCpuPercent(const QList<double> &cpuTimes, const int &processor = 0) const;
Expand Down
1 change: 0 additions & 1 deletion stacer/Pages/Resources/resources_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ void ResourcesPage::init()
ui->chartsLayout->addWidget(cpuChart);
ui->chartsLayout->addWidget(memoryChart);
ui->chartsLayout->addWidget(networkChart);
ui->chartsLayout->addWidget(new QPushButton("asdsdsad"));

connect(timer, &QTimer::timeout, this, &ResourcesPage::updateCpuChart);
connect(timer, &QTimer::timeout, this, &ResourcesPage::updateMemoryChart);
Expand Down

0 comments on commit 728c65c

Please sign in to comment.