2022年5月10日 星期二

Process memory usage

 Process memory usage

GetProcessWorkingSetSize() SetProcessWorkingSetSize()   
h,mMin,mMax:cardinal;
h:=OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, false, PID);
GetProcessWorkingSetSize(h,mMin,mMax);
CloseHandle(h);
h,newMin,newMax:cardinal;
h:=OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_SET_QUOTA, false, PID);
SetProcessWorkingSetSize(h, newMin, newMax);

https://w-shadow.com/blog/2006/09/04/process-memory-usage/ 




GetSystemTimes to get the total system timing.

GetProcessTimes to get timing for a specific process.

GetCurrentProcess to get current process handle.

PerfCounter Performance Counter

https://docs.microsoft.com/zh-tw/troubleshoot/windows-server/performance/manually-rebuild-performance-counters

https://www.codeproject.com/articles/9113/get-cpu-usage-with-getsystemtimes

https://docs.microsoft.com/en-us/windows/win32/perfctrs/about-performance-counters

https://www.codeproject.com/Articles/10538/Getting-CPU-Usage-in-a-Multiprocessor-Machine

https://www.codeproject.com/search.aspx?q=cpu++usage&doctypeid=1%3b2%3b3%3b13%3b11%3b17

delphi Multicore library parallel programming

 Using TTask from the Parallel Programming Library
https://docwiki.embarcadero.com › Sydney
 
TTask creates and manages interaction with instances of ITask. ITask is an interface that provides a range of methods and properties to Start, Wait, Cancel and ...
 


    System.Threading.TTask - RAD Studio API Documentation
    https://docwiki.embarcadero.com › Syste...

   
    TTask is a class managing and representing procedures that can be executed in parallel threads. An instance of TTask represents a single task or unit of ...


delphi Parallel 之TTask 初試- 程式人生
https://www.itread01.com › content
  — Clear; SetLength(TaskArray, C); for I := 0 to C - 1 do begin TaskArray[I] := TTask.Create(procedure var Id: string; begin Id := TThread.

Introducing the TTask class | Delphi GUI Programming with ...
https://subscription.packtpub.com › book
 
TTask.Run( procedure begin // Do something end ); Copy. We should recall the TThread.CreateAnonymousThread class function but a bit more abstracted.

 

https://www.codetd.com/en/article/9464576

 http://delphi.org/2015/02/parallel-for-loops/

https://github.com/MarcoDelphiBooks/ObjectPascalHandbook104

 https://grantmcdermott.com/ds4e/parallel.html

https://github.com/eStreamSoftware/delphi-ppl 



delphi CPU  affinity mask  Thread Affinity Mask


SetProcessAffinityMask - Select more than one processor?

https://stackoverflow.com/questions/9078838/setprocessaffinitymask-select-more-than-one-processor
function CombinedProcessorMask(const Processors: array of Integer): DWORD_PTR;
  i: Integer;
  Result := 0;
  for i := low(Processors) to high(Processors) do
    Result := Result or SingleProcessorMask(Processors[i]);
function ProcessorInMask(const ProcessorMask: DWORD_PTR;
  const ProcessorIndex: Integer): Boolean;
  Result := (SingleProcessorMask(ProcessorIndex) and ProcessorMask)<>0;
 

得知自己在某個cpu core 上


https://stackoverflow.com/questions/33571061/get-the-percentage-of-total-cpu-usage

Get the Percentage of Total CPU Usage

CPU 負載

https://github.com/aadamfr/Super_macro/blob/master/adCpuUsage.pas 

AdCpuUsage

 

 How to monitor CPU and network utilization

https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/mt708809(v=vs.85)