cpu-usage

Reading on a NetworkStream = 100% CPU usage

霸气de小男生 提交于 2019-12-29 07:55:31
问题 I am reading from a NetworkStream that is in a while loop. The issue is I am seeing 100% CPU usage. Is there any way to stop this from happening? Here is what I have so far: while (client != null && client.Connected) { NetworkStream stream = client.GetStream(); data = null; try { // Check if we are still connected. if (client.Client.Poll(0, SelectMode.SelectRead)) { byte[] checkConn = new byte[1]; if (client.Client.Receive(checkConn, SocketFlags.Peek) == 0) { throw new IOException(); } } if

How can I get CPU usage and/or RAM usage of a *THREAD* in C# (managed code)?

百般思念 提交于 2019-12-28 13:22:19
问题 I know how to get CPU usage and memory usage for a process, but I was wondering how to get it on a per-thread level. If the best solution is to do some P-Invoking, then that's fine too. Example of what I need: Thread myThread = Thread.CurrentThread; // some time later in some other function... Console.WriteLine(GetThreadSpecificCpuUsage(myThread)); 回答1: Here's an example which does what you want http://www.codeproject.com/KB/system/processescpuusage.aspx 回答2: As said, memory use cannot be

I need a slow C# function

非 Y 不嫁゛ 提交于 2019-12-28 05:37:28
问题 For some testing I'm doing I need a C# function that takes around 10 seconds to execute. It will be called from an ASPX page, but I need the function to eat up CPU time on the server, not rendering time. A slow query into the Northwinds database would work, or some very slow calculations. Any ideas? 回答1: Try to calculate nth prime number to simulate CPU intensive work - public void Slow() { long nthPrime = FindPrimeNumber(1000); //set higher value for more time } public long FindPrimeNumber

How to get the cpu usage per thread on windows (win32)

筅森魡賤 提交于 2019-12-27 12:01:10
问题 Looking for Win32 API functions, C++ or Delphi sample code that tells me the CPU usage (percent and/or total CPU time) of a thread (not the total for a process). I have the thread ID. I know that Sysinternals Process Explorer can display this information, but I need this information inside my program. 回答1: You must use these functions to get the cpu usage per thread and process. GetThreadTimes (Retrieves timing information for the specified thread.) GetProcessTimes (Retrieves timing

How to get the cpu usage per thread on windows (win32)

℡╲_俬逩灬. 提交于 2019-12-27 12:00:07
问题 Looking for Win32 API functions, C++ or Delphi sample code that tells me the CPU usage (percent and/or total CPU time) of a thread (not the total for a process). I have the thread ID. I know that Sysinternals Process Explorer can display this information, but I need this information inside my program. 回答1: You must use these functions to get the cpu usage per thread and process. GetThreadTimes (Retrieves timing information for the specified thread.) GetProcessTimes (Retrieves timing

How to choose the right buffer to draw and stop it from swapping continuously

假装没事ソ 提交于 2019-12-25 19:05:19
问题 Please tell me if the question's vogue, I need the answe as soon as possible for more information about the problem you can refer to this. I just didn't understand how to manage buffers properly. A red rectangle drawn on 2D texture disappears right after being drawn Being in the last stages of customizing the class COpenGLControl: I have created two instances of the class in my MFC Dialog: whenever the extent of zoom is changed in the bigger window, it is drawn as a red rectangle on the

Constantly repainting a scene of 8000 invisible items, when a MouseArea also exists, causes high CPU usage

守給你的承諾、 提交于 2019-12-25 09:26:05
问题 How to reproduce: Run my code Keep the mouse over the window that appears You'll see that CPU usage is fairly high, although it will depend on your hardware. On my PC it's 20% (5% in each of the 4 virtual cores). My motivation for this testcase: in my real app I have a lot of invisible (culled) items, and while that the culling helps a lot with the CPU usage, it doesn't help as much as I'd expect. I'd like ideas on why the CPU usage is so high, and how to reduce it. My code : main.qml :

CPU Usage of every process

依然范特西╮ 提交于 2019-12-25 07:47:44
问题 I found this code on google that calculate of % of usage of current process on win10,but what i'm looking for is a list of % of CPU Usage of every process. I use GetCurrentProcess() to have the handle of the current process. Is there a way to retrieve the handle of every processes?i'm working on a code that lists running process and calculate usage memory for everyone. Then i need to calculate cpu usage for everyone but i didn't find anything on google. static ULARGE_INTEGER lastCPU,

Which one will workload(usage) of the CPU-Core if there is a persistent cache-miss, will be 100%?

别等时光非礼了梦想. 提交于 2019-12-25 05:00:31
问题 That is, if the core processor most of the time waiting for data from RAM or cache-L3 with cache-miss, but the system is a real-time (real-time thread priority), and the thread is attached (affinity) to the core and works without switching thread/context, what kind of load(usage) CPU-Core should show on modern x86_64 ? That is, CPU usage is displayed as decrease only when logged in Idle ? And if anyone knows, if the behavior is different in this case for other processors: ARM, Power[PC],

Get system memory and CPU usage from within C++11 code [duplicate]

扶醉桌前 提交于 2019-12-25 01:48:28
问题 This question already has answers here : How to determine CPU and memory consumption from inside a process? (9 answers) Closed last year . How can I get the total percentage or volume of memory usage and CPU consumption from within C++11 code on ubuntu (or any other linux-based system)? The usage I want to get is for the whole system, not just for current thread or process. 回答1: Read about proc(5) and use /proc/meminfo . You can open it and read it as a sequential file (even if it often