mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-03 12:35:51 +00:00
Better CPU frequency detection for Linux
This commit is contained in:
parent
50c543d73a
commit
be35f67bc9
@ -9,6 +9,7 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QStorageInfo>
|
#include <QStorageInfo>
|
||||||
#include "FindBlender.hpp"
|
#include "FindBlender.hpp"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
@ -45,23 +46,12 @@ SysReqTableModel::SysReqTableModel(QObject* parent)
|
|||||||
: QAbstractTableModel(parent)
|
: QAbstractTableModel(parent)
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
QProcess lscpuProc;
|
QFile file("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq");
|
||||||
lscpuProc.start("lscpu", {"-J"}, QProcess::ReadOnly);
|
if (file.open(QFile::ReadOnly))
|
||||||
lscpuProc.waitForFinished();
|
|
||||||
QJsonDocument lscpu = QJsonDocument::fromJson(lscpuProc.readAll());
|
|
||||||
QJsonValue lscpuObj = lscpu.object().take("lscpu");
|
|
||||||
if (lscpuObj.type() == QJsonValue::Array)
|
|
||||||
{
|
{
|
||||||
for (const QJsonValue& v: lscpuObj.toArray())
|
QString str(file.readAll());
|
||||||
{
|
m_cpuSpeed = str.toInt() / 1000;
|
||||||
QJsonObject vObj = v.toObject();
|
m_cpuSpeedStr.sprintf("%g GHz", m_cpuSpeed / 1000.0);
|
||||||
if (vObj.take("field").toString() == "CPU max MHz:")
|
|
||||||
{
|
|
||||||
double speed = vObj.take("data").toString().toDouble();
|
|
||||||
m_cpuSpeed = speed;
|
|
||||||
m_cpuSpeedStr.sprintf("%g GHz", speed / 1000.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
QProcess spProc;
|
QProcess spProc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user