| 1 2 3 4 5 6
msg.MemoryGlobalUsage->push_back(((double)statex.ullTotalPhys - (double)statex.ullAvailPhys) / (double)statex.ullTotalPhys) ;
if(msg.MemoryGlobalUsage->size() > msg.Count)
msg.MemoryGlobalUsage->pop_front(); //Використання памяті процесом
GetProcessMemoryInfo(hProc, ppsmemCounters, sizeof(*ppsmemCounters));
msg.MemoryProcUsage->push_back((double)ppsmemCounters->WorkingSetSize / (double)statex.ullTotalPhys) ;
if(msg.MemoryProcUsage->size() > msg.Count)
msg.MemoryProcUsage->pop_front(); //Використання процесора - глобальне
LPFILETIME idleTime = new _FILETIME();
LPFILETIME kernelTime = new _FILETIME();
LPFILETIME userTime = new _FILETIME(); GetSystemTimes( idleTime, kernelTime, userTime ); _int64 IdleTime;
_int64 KernelTime;
_int64 UserTime; (*(LARGE_INTEGER*)&IdleTime).HighPart = idleTime->dwHighDateTime;
(*(LARGE_INTEGER*)&IdleTime).LowPart = idleTime->dwLowDateTime; (*(LARGE_INTEGER*)&KernelTime).HighPart = kernelTime->dwHighDateTime;
(*(LARGE_INTEGER*)&KernelTime).LowPart = kernelTime->dwLowDateTime; (*(LARGE_INTEGER*)&UserTime).HighPart = userTime->dwHighDateTime;
(*(LARGE_INTEGER*)&UserTime).LowPart = userTime->dwLowDateTime; double d; if(lKernelTime == 0 && lUserTime == 0 && lIdleTime == 0)
d = 0;
else
d = (double)(UserTime - lUserTime + KernelTime - lKernelTime - (IdleTime - lIdleTime))/
(UserTime - lUserTime + KernelTime - lKernelTime);
msg.CPUglobalUsage->push_back(d) ;
if(msg.CPUglobalUsage->size() > msg.Count)
msg.CPUglobalUsage->pop_front();
//Використання процесора процесом
LPFILETIME lpKernelTime = new _FILETIME();
LPFILETIME lpUserTime= new _FILETIME();
LPFILETIME lpCreationTime= new _FILETIME();
LPFILETIME lpExitTime= new _FILETIME(); HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS,false,msg.ProcId);
GetProcessTimes(hProc, lpCreationTime, lpExitTime, lpKernelTime, lpUserTime); _int64 ProcessKernelTime ;
(*(LARGE_INTEGER*)&ProcessKernelTime).HighPart = lpKernelTime->dwHighDateTime;
(*(LARGE_INTEGER*)&ProcessKernelTime).LowPart = lpKernelTime->dwLowDateTime; _int64 ProcessUserTime ;
(*(LARGE_INTEGER*)&ProcessUserTime).HighPart = lpUserTime->dwHighDateTime;
(*(LARGE_INTEGER*)&ProcessUserTime).LowPart = lpUserTime->dwLowDateTime; _int64 ProcessTotalTime = ProcessUserTime + ProcessKernelTime; if( lUserTime + lKernelTime + lIdleTime == 0)
d = 0;
else
d = (double)(ProcessTotalTime - lPTotalTime) /
(double)(UserTime - lUserTime + KernelTime - lKernelTime ); msg.CPUprocUsage->push_back(d) ;
if(msg.CPUprocUsage->size() > msg.Count)
msg.CPUprocUsage->pop_front();
lPTotalTime = ProcessTotalTime;
lUserTime = UserTime;
lKernelTime = KernelTime;
lIdleTime = IdleTime; //Спати, бо 6:30 ранку
Sleep(msg.TimeOut);
} } namespace kursec { using namespace System;
using namespace System::Threading;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Runtime::InteropServices;
///
/// Summary for Form1
///
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent(); frmAttach = (gcnew ChooseProc());
frmStart = (gcnew StartProc()); //
//TODO: Add the constructor code here
//
} protected:
///
/// Clean up any resources being used.
///
Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::MenuStrip^ mnuMain;
protected: private: Thread^ DebugEvents;
private: Thread^ PerfInf; private: ChooseProc^ frmAttach;
private: StartProc^ frmStart; private: System::Windows::Forms::ToolStripMenuItem^ профілюванняToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ підключитиПроцесToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ запуститиПроцесToolStripMenuItem;
private: System::Windows::Forms::ToolStripSeparator^ toolStripMenuItem1;
private: System::Windows::Forms::ToolStripMenuItem^ вихідToolStripMenuItem;
private: System::Windows::Forms::Timer^ tmrTime;
private: System::Windows::Forms::SplitContainer^ splitContainer1;
private: System::Windows::Forms::SplitContainer^ splitContainer2;
private: System::Windows::Forms::PictureBox^ picProc;
private: System::Windows::Forms::PictureBox^ picMem;
private: System::Windows::Forms::SplitContainer^ splitContainer3;
private: System::Windows::Forms::Label^ lblName;
private: System::Windows::Forms::Label^ label13;
private: System::Windows::Forms::Label^ lblParId;
private: System::Windows::Forms::Label^ label12;
private: System::Windows::Forms::Label^ lblTHR;
private: System::Windows::Forms::Label^ label11;
private: System::Windows::Forms::Label^ lblPPFU;
private: System::Windows::Forms::Label^ lblPFU;
private: System::Windows::Forms::Label^ lblPWSS;
private: System::Windows::Forms::Label^ lblWS;
private: System::Windows::Forms::Label^ lblPid;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ lblQNPPU;
private: System::Windows::Forms::Label^ lblQPPU;
private: System::Windows::Forms::Label^ label9;
private: System::Windows::Forms::Label^ label7;
private: System::Windows::Forms::ListBox^ lstEvents;
private: System::ComponentModel::IContainer^ components; private:
///
/// Required designer variable.
///
#pragma region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
void InitializeComponent(void)
{
this->components = (gcnew System::ComponentModel::Container());
this->mnuMain = (gcnew System::Windows::Forms::MenuStrip());
this->профілюванняToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->підключитиПроцесToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->запуститиПроцесToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->toolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripSeparator());
this->вихідToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->tmrTime = (gcnew System::Windows::Forms::Timer(this->components));
this->splitContainer1 = (gcnew System::Windows::Forms::SplitContainer());
this->splitContainer2 = (gcnew System::Windows::Forms::SplitContainer());
this->picProc = (gcnew System::Windows::Forms::PictureBox());
this->picMem = (gcnew System::Windows::Forms::PictureBox());
this->splitContainer3 = (gcnew System::Windows::Forms::SplitContainer());
this->lstEvents = (gcnew System::Windows::Forms::ListBox());
this->lblName = (gcnew System::Windows::Forms::Label());
this->label13 = (gcnew System::Windows::Forms::Label());
this->lblParId = (gcnew System::Windows::Forms::Label());
this->label12 = (gcnew System::Windows::Forms::Label());
this->lblTHR = (gcnew System::Windows::Forms::Label());
this->label11 = (gcnew System::Windows::Forms::Label());
this->lblPPFU = (gcnew System::Windows::Forms::Label());
this->lblPFU = (gcnew System::Windows::Forms::Label());
this->lblPWSS = (gcnew System::Windows::Forms::Label());
this->lblWS = (gcnew System::Windows::Forms::Label());
this->lblPid = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label1 = (gcnew System::Windows::Forms::Label());
this->lblQNPPU = (gcnew System::Windows::Forms::Label());
this->lblQPPU = (gcnew System::Windows::Forms::Label());
this->label9 = (gcnew System::Windows::Forms::Label());
this->label7 = (gcnew System::Windows::Forms::Label());
this->mnuMain->SuspendLayout();
(cli::safe_cast(this->splitContainer1))->BeginInit();
this->splitContainer1->Panel1->SuspendLayout();
this->splitContainer1->Panel2->SuspendLayout();
this->splitContainer1->SuspendLayout();
(cli::safe_cast(this->splitContainer2))->BeginInit();
this->splitContainer2->Panel1->SuspendLayout();
this->splitContainer2->Panel2->SuspendLayout();
this->splitContainer2->SuspendLayout();
(cli::safe_cast(this->picProc))->BeginInit();
(cli::safe_cast(this->picMem))->BeginInit();
(cli::safe_cast(this->splitContainer3))->BeginInit();
this->splitContainer3->Panel1->SuspendLayout();
this->splitContainer3->Panel2->SuspendLayout();
this->splitContainer3->SuspendLayout();
this->SuspendLayout();
//
// mnuMain
//
this->mnuMain->AccessibleRole = System::Windows::Forms::AccessibleRole::MenuBar;
this->mnuMain->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) {this->профілюванняToolStripMenuItem});
this->mnuMain->Location = System::Drawing::Point(0, 0);
this->mnuMain->Name = L"mnuMain";
this->mnuMain->Size = System::Drawing::Size(1066, 24);
this->mnuMain->TabIndex = 0;
this->mnuMain->Text = L"menuStrip1";
//
// профілюванняToolStripMenuItem
//
this->профілюванняToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(4) {this->підключитиПроцесToolStripMenuItem,
this->запуститиПроцесToolStripMenuItem, this->toolStripMenuItem1, this->вихідToolStripMenuItem});
this->профілюванняToolStripMenuItem->Name = L"профілюванняToolStripMenuItem";
this->профілюванняToolStripMenuItem->Size = System::Drawing::Size(103, 20);
this->профілюванняToolStripMenuItem->Text = L"Профілювання";
//
// підключитиПроцесToolStripMenuItem
//
this->підключитиПроцесToolStripMenuItem->Name = L"підключитиПроцесToolStripMenuItem";
this->підключитиПроцесToolStripMenuItem->ShortcutKeys = static_cast((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::A));
this->підключитиПроцесToolStripMenuItem->Size = System::Drawing::Size(226, 22);
this->підключитиПроцесToolStripMenuItem->Text = L"Підключити процес";
this->підключитиПроцесToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::підключитиПроцесToolStripMenuItem_Click);
//
// запуститиПроцесToolStripMenuItem
//
this->запуститиПроцесToolStripMenuItem->Name = L"запуститиПроцесToolStripMenuItem";
this->запуститиПроцесToolStripMenuItem->ShortcutKeys = static_cast((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::S));
this->запуститиПроцесToolStripMenuItem->Size = System::Drawing::Size(226, 22);
this->запуститиПроцесToolStripMenuItem->Text = L"Запустити процес";
this->запуститиПроцесToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::запуститиПроцесToolStripMenuItem_Click);
//
// toolStripMenuItem1
//
this->toolStripMenuItem1->Name = L"toolStripMenuItem1";
this->toolStripMenuItem1->Size = System::Drawing::Size(223, 6);
//
// вихідToolStripMenuItem
//
this->вихідToolStripMenuItem->Name = L"вихідToolStripMenuItem";
this->вихідToolStripMenuItem->Size = System::Drawing::Size(226, 22);
this->вихідToolStripMenuItem->Text = L"Вихід";
this->вихідToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::вихідToolStripMenuItem_Click);
//
// tmrTime
//
this->tmrTime->Interval = 50;
this->tmrTime->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
//
// splitContainer1
//
this->splitContainer1->Dock = System::Windows::Forms::DockStyle::Fill;
this->splitContainer1->Location = System::Drawing::Point(0, 24);
this->splitContainer1->Name = L"splitContainer1";
//
// splitContainer1.Panel1
//
this->splitContainer1->Panel1->Controls->Add(this->splitContainer3);
//
// splitContainer1.Panel2
//
this->splitContainer1->Panel2->Controls->Add(this->splitContainer2);
this->splitContainer1->Size = System::Drawing::Size(1066, 692);
this->splitContainer1->SplitterDistance = 488;
this->splitContainer1->TabIndex = 5;
//
// splitContainer2
//
this->splitContainer2->Dock = System::Windows::Forms::DockStyle::Fill;
this->splitContainer2->Location = System::Drawing::Point(0, 0);
this->splitContainer2->Name = L"splitContainer2";
this->splitContainer2->Orientation = System::Windows::Forms::Orientation::Horizontal;
//
// splitContainer2.Panel1
//
this->splitContainer2->Panel1->Controls->Add(this->picProc);
//
// splitContainer2.Panel2
//
this->splitContainer2->Panel2->Controls->Add(this->picMem);
this->splitContainer2->Size = System::Drawing::Size(574, 692);
this->splitContainer2->SplitterDistance = 336;
this->splitContainer2->SplitterIncrement = 10;
this->splitContainer2->TabIndex = 31;
//
// picProc
//
this->picProc->BackColor = System::Drawing::Color::FromArgb(static_cast(static_cast(64)), static_cast(static_cast(64)),
static_cast(static_cast(64)));
this->picProc->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
this->picProc->Dock = System::Windows::Forms::DockStyle::Fill;
this->picProc->Location = System::Drawing::Point(0, 0);
this->picProc->Name = L"picProc";
this->picProc->Size = System::Drawing::Size(574, 336);
this->picProc->TabIndex = 31;
this->picProc->TabStop = false;
this->picProc->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::picProc_Paint);
//
// picMem
//
this->picMem->BackColor = System::Drawing::Color::FromArgb(static_cast(static_cast(64)), static_cast(static_cast(64)),
static_cast(static_cast(64)));
this->picMem->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
this->picMem->Dock = System::Windows::Forms::DockStyle::Fill;
this->picMem->Location = System::Drawing::Point(0, 0);
this->picMem->Name = L"picMem";
this->picMem->Size = System::Drawing::Size(574, 352);
this->picMem->TabIndex = 30;
this->picMem->TabStop = false;
this->picMem->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::picMem_Paint);
//
// splitContainer3
//
this->splitContainer3->Dock = System::Windows::Forms::DockStyle::Fill;
this->splitContainer3->IsSplitterFixed = true;
this->splitContainer3->Location = System::Drawing::Point(0, 0);
this->splitContainer3->Name = L"splitContainer3";
this->splitContainer3->Orientation = System::Windows::Forms::Orientation::Horizontal;
//
// splitContainer3.Panel1
//
this->splitContainer3->Panel1->Controls->Add(this->lblName);
this->splitContainer3->Panel1->Controls->Add(this->label13);
1 2 3 4 5 6
скачати
|