Skip to content

Commit

Permalink
Performance monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud LE CAM authored and elieserdejesus committed Apr 9, 2020
1 parent c97ce14 commit a4defcd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Common/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void MainWindow::setupMainTabCornerWidgets()
performanceMonitorLabel->setObjectName(QStringLiteral("labelPerformanceMonitor"));

#ifndef Q_OS_WIN
performanceMonitorLabel->setVisible(false); // showing RAM monitor in windows only
performanceMonitorLabel->setVisible(false); // showing RAM monitor in windows only
#endif

transmitTransferRateLabel = new QLabel(this);
Expand Down Expand Up @@ -2094,7 +2094,7 @@ void MainWindow::timerEvent(QTimerEvent *)
ninjamWindow->updatePeaks();
}

// update cpu and memmory usage
// update cpu and RAM usage
qint64 now = QDateTime::currentMSecsSinceEpoch();
if (now - lastPerformanceMonitorUpdate >= PERFORMANCE_MONITOR_REFRESH_TIME) {

Expand All @@ -2103,7 +2103,7 @@ void MainWindow::timerEvent(QTimerEvent *)
auto memmoryUsed = performanceMonitor->getMemmoryUsed();
auto batteryUsed = performanceMonitor->getBatteryUsed();

bool showMemmory = memmoryUsed > 60; //memory meter only active if memory usage is <60%
bool showMemmory = memmoryUsed > 60; //memory meter only active (as an alert) if RAM usage is > 60%
bool showBattery = batteryUsed < 255; //Battery meter active only if battery is available

QString string;
Expand Down
7 changes: 5 additions & 2 deletions src/Common/performance/LinuxPerformanceMonitor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "PerformanceMonitor.h"

#include "sys/sysinfo.h"

PerformanceMonitor::PerformanceMonitor(){

Expand All @@ -10,8 +11,10 @@ PerformanceMonitor::~PerformanceMonitor(){
}

int PerformanceMonitor::getMemmoryUsed(){

return 0;
struct sysinfo memInfo;
sysinfo (&memInfo);
long long virtualMemUsed = memInfo.totalram - memInfo.freeram ;
return 100 * virtualMemUsed / memInfo.totalram;
}

int PerformanceMonitor::getBatteryUsed()
Expand Down
2 changes: 1 addition & 1 deletion src/Common/performance/WindowsPerformanceMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ PerformanceMonitor::~PerformanceMonitor()
int PerformanceMonitor::getMemmoryUsed()
{

//http://stackoverflow.com/questions/63166/how-to-determine-cpu-and-memory-consumption-from-inside-a-process
//https://stackoverflow.com/questions/63166/how-to-determine-cpu-and-memory-consumption-from-inside-a-process
MEMORYSTATUSEX memInfo;
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
bool result = GlobalMemoryStatusEx(&memInfo);
Expand Down

0 comments on commit a4defcd

Please sign in to comment.