Vielleicht übersehe ich den Punkt, aber es scheint eine beliebte Methode zu sein, die CPU zwei Mal mit mindestens 200 ms zwischen jeder Prüfung abzufragen, um Probleme mit etwas namens ... Auflösung zu vermeiden? Also ja! Wie zum Teufel mache ich das?
Vorabwarnung: Es tut mir so leid für alle Kommentare im Code
Code: Select all
//included libraries/functionality for input/output
#include
#include
#include
using namespace std;
//creates a static variable to convert Bytes to Megabytes
#define MB 1048576
//main program code loop
int main()
{
//Code block intiialization for the memory referenced in the Kernell
MEMORYSTATUSEX memStat;
memStat.dwLength = sizeof (memStat);
GlobalMemoryStatusEx(&memStat);
//loads the SYSTEMTIME
SYSTEMTIME sysTime;
//Retrieves data so that we have a way to Get it to output when using the pointers
GetSystemTime(&sysTime);
//setting the I/O for our log file to be "myfile"
ofstream myfile;
// ios::out means that we're outputting data to the file
// ios::app means that all the data we're outputting goes to the end of that log file instead of the start
myfile.open("log.csv", ios::out | ios::app);
//a while loop that gathers and logs data every quarter of a second to gather 4 data points in one second
int counter = 0;
while (counter < 4)
{
//Timestamp + Memory Info, and eventually CPU Load percentage
myfile
Mobile version