Build 600+ and CPU usage - page 6

 
RaptorUK:

I wonder if you could check something for me in your Process Explorer ?

If you find the terminal.exe process, double click it then go to the Threads tab . . . do you have one or two threads called terminal.exe+ . .. . I have two . . .

if I kill the one using the CPU MT4 still appears to run OK but at a much lower CPU usage.

With pleasure but I need to install some Microsoft Debugging Tools for Windows...I will post the result as soon I get it.
 

here is basic, work it out for your needs

//+------------------------------------------------------------------+
//|                                                       !pCPUu.mq4 |
//+------------------------------------------------------------------+
#property version   "1.00"

#import "Psapi.dll"
   bool EnumProcesses(int& pProcessIds[], int cb, int & pBytesReturned);
   int  GetModuleBaseNameW(int hProcess, int & hModule[], char & lpBaseName[], int nSize);
   int  GetModuleFileNameExW(int hProcess, int & hModule[],ushort & lpFilename[], int nSize);
   bool EnumProcessModules(int hProcess,int & lphModule[],int cb, int & lpcbNeeded[]);

#import

#import "kernel32.dll"
   int  OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
   bool GetProcessTimes(int hProcess, int & lpCreationTime[], int & lpExitTime[], int & lpKernelTime[], int & lpUserTime[]);
   bool GetSystemTimes(int & lpIdleTime[], int & lpKernelTime[], int & lpUserTime[]);
   int  GetLastError(void);
#import
#define PROCESS_QUERY_INFORMATION 0x0400
#define PROCESS_VM_READ 0x0010

double   CPU_Usage;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   EventSetTimer(1);
      
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
      
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   int aProcesses[1024], cbNeeded, cProcesses, hMod[], szPN[1024], sz;
   int lpCreationTimeF[1], lpExitTimeF[1], lpKernelTimeF[1], lpUserTimeF[1];
   int lpCreationTimeS[1], lpExitTimeS[1], lpKernelTimeS[1], lpUserTimeS[1];
   string Prss;
            
   
   EnumProcesses(aProcesses, ArraySize(aProcesses), cbNeeded); // Get the list of process identifiers.
   cProcesses = cbNeeded / 4; // Calculate how many process identifiers were returned.
   for (int i = 0; i < cProcesses; i++)
      {
      if(aProcesses[i] != 0 )
         {
         // Get a handle to the process.
         int hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, aProcesses[i]);
         if (hProcess != 0)
            {
            // Get the process name.
            if (EnumProcessModules(hProcess, hMod, ArraySize(hMod), szPN))
               {
               ushort szProcessName[1850];
               GetModuleFileNameExW(hProcess, hMod, szProcessName, ArraySize(szProcessName)/32 );
               Prss = ShortArrayToString(szProcessName);
               if (StringFind(Prss, "terminal.exe") != -1)
                  {
                  // Calculate the process CPU usage
                  GetProcessTimes(hProcess, lpCreationTimeF, lpExitTimeF, lpKernelTimeF, lpUserTimeF);
                  Sleep(1000);
                  GetProcessTimes(hProcess, lpCreationTimeS, lpExitTimeS, lpKernelTimeS, lpUserTimeS);
                  CPU_Usage=((((lpKernelTimeS[0]-lpKernelTimeF[0]) + (lpUserTimeS[0] - lpUserTimeF[0])) * 100) / 10000000);
                  if (CPU_Usage > 10)
                  Alert(Prss, " is: ", CPU_Usage, " Prss no=: ", aProcesses[i]);
                  }
               }
            }
         }
      }   
  }
 
SDC:

on the terminal process I dont know how to do it so im hacking at it right now trying different things I managed to almost get it but it says _total where I think it should say terminal. I dont want the CPU stats on everything I just want it to do MT4 the same as when i add the MT4 process counter to the graphical display chart ...

You have to choose the processus when you are adding the Counter. Processus then %CPU time and choose the process. (I am working in french so not sure of the exact term in English).
 
angevoyageur:
With pleasure but I need to install some Microsoft Debugging Tools for Windows...I will post the result as soon I get it.

Ok. There is something weird. I have 3 threads, but it seems that the %cpu increased since I am playing with this. I will do some checks and report about it.
 
I have two of those terminal.exe+ threads in mine I dont think you should kill one of them they seem to be doing quite a lot if you check the stacks on them and keep refreshing
 
angevoyageur:
You have to choose the processus when you are adding the Counter. Processus then %CPU time and choose the process. (I am working in french so not sure of the exact term in English).
ok I'll try that again
 
RaptorUK:

I wonder if you could check something for me in your Process Explorer ?

If you find the terminal.exe process, double click it then go to the Threads tab . . . do you have one or two threads called terminal.exe+ . .. . I have two . . .

if I kill the one using the CPU MT4 still appears to run OK but at a much lower CPU usage.


It tried killing it, but I got no more incoming ticks.

According to my motherboard power monitoring utility b625 uses about 5W on my CPU, whereas b509 uses about 1W. This seems to back up the CPU figures from Process Explorer.

 
euclid:


It tried killing it, but I got no more incoming ticks.

According to my motherboard power monitoring utility b625 uses about 5W on my CPU, whereas b509 uses about 1W. This seems to back up the CPU figures from Process Explorer.

Yes I discovered that too . . .
 
angevoyageur:
Ok. There is something weird. I have 3 threads, but it seems that the %cpu increased since I am playing with this. I will do some checks and report about it.
No I can't see anything useful. I currently have 2 terminal threads (with no charts, no symbols) and %cpu varying from 0.8% to 2.1%, despite the fact the platform is supposed to do nothing. When I open a chart and show all symbols, this % is around 3-4%.
 
angevoyageur:
No I can't see anything useful. I currently have 2 terminal threads (with no charts, no symbols) and %cpu varying from 0.8% to 2.1%, despite the fact the platform is supposed to do nothing. When I open a chart and show all symbols, this % is around 3-4%.
Is it because the platform is still accepting incomming ticks ?
Reason: