This question already has answers here:
How to get memory usage under Windows in C++
(5 answers)
Closed 9 years ago.
Under windows, given a PID:
1) How to get the exact memory in bytes and
2) The exact CPU usage
consumed by that application right now?
See GetProcessMemoryInfo, and specifically the WorkingSetSize field of the out parameter.
GetProcessTimes will let you know how much time your process has spent altogether in user & kernel space. It's up to you to calculate percentages, or whatever you want out of it.
Related
This question already has answers here:
How to determine CPU and memory consumption from inside a process
(10 answers)
Closed 7 years ago.
I have a few threads in my program - run on Windows and write in C++.
How can I know in the end of the running how much CPU time is used by all or one of them?
You can use the GetThreadTimes function: https://msdn.microsoft.com/en-us/library/windows/desktop/ms683237%28v=vs.85%29.aspx
This question already has answers here:
C++ cache aware programming
(10 answers)
Closed 7 years ago.
I am profiling my code on various CPUs running Windows7 and my results so far suggest that I need to tune a buffer size proportional to the machine's L2CacheSize or L3CacheSize. Is there a way to obtain these parameters from C++?
You can use the GetLogicalProcessorInformation function to get that. It returns an array of SYSTEM_LOGICAL_PROCESSOR_INFORMATION structures which contain a CACHE_DESCRIPTOR structure, which provides the cache size information.
This question already has answers here:
Getting memory information with Qt
(3 answers)
How to get memory usage at runtime using C++?
(11 answers)
Closed 8 years ago.
I am looking for a way to retrieve the RAM memory size of my computer in C++ with Qt.
My primary target is Windows, if that would make things easier.
This question already has answers here:
How to measure the inner kernel time in NVIDIA CUDA?
(2 answers)
Closed 8 years ago.
I searched a bit but all things I found could only be annotated in CPU code, how could I measure partial time inside kernel between 2 _syncthread() of 1 threadblock? Is it possible?
One approach is to use the clock() or clock64 function as described in the programming guide.
Search the cuda tag on clock64 for additional examples of its usage.
This question already has answers here:
How to detect win32 process creation/termination in c++
(9 answers)
Closed 9 years ago.
I am looking for a WIN 32 API to detect application launch and termination in my application.
I am looking to develop a dockBar/TaskBar for which I need to get handle of application that are launch and terminate.
For a DockBar/TaskBar have a look at the RegisterShellHookWindow function.
Specifically, the HSHELL_WINDOWCREATED and HSHELL_WINDOWDESTROYED notification.