开发者

Running Visual Studio console application in debug mode consumes no more than 50 percent cpu usage

开发者 https://www.devze.com 2022-12-08 04:26 出处:网络
I have a several C# console applications that basically parse ton开发者_如何学编程s of data in memory (LINQ) and output the results to a text file.

I have a several C# console applications that basically parse ton开发者_如何学编程s of data in memory (LINQ) and output the results to a text file.

Now, forget about the writing to the text file for a minute because this is not where the problem is occurring.

When I run the application in debug mode, I will never get it to utilize more than 50% of cpu usage. It will be parsing/massaging hundreds of thousands of records, but only go X fast and utilize 50% of the cpu AT MOST (as viewed in the Task Manager).

I would really like to use 100% of the CPU to make the processing go faster.

Does anybody have any insight?

I am running Windows XP Professional with Service Pack 3. I have Visual Studio 2008 Professional with Service Pack 1 installed.

Thanks!

EDIT:

  • I have manually set the affinity of the process in Task Manager to a single core on the dual CPU.
  • Sometimes I can catch it utilizing 51% or 52% of the CPU.


It sounds like you have a dual-core CPU and your application is single-threaded.


Sounds like you have a dual core cpu. Setting the processor affinity won't do anything to speed up your program. Also the 51/52% you see are other processes running on the other core at 1-2% PLUS your program running on the first core at full speed.

If you want to attempt to make your program use both cores, try looking into PLINQ in the Parallel Extensions library.

Parallel Extensions Library

Plinq Article


If your application executes on only one thread and you happen to have a dual core processor only one of the cores will be used, thus you use 50% of the available processor power.

If you have the possiblity to divide the work into logical pieces and spawn threads dealing with those pieces you may use both cores.


You have a processor with two cores. Your application only has one thread, which can only run on one core. It utilizes this core to 100%. If you want to use the other core as well, you'll have to use more threads.


As others have said, your app is running on one core of your dual (2) core CPU. When you see 50% in Task Manager, it means that the core that is running your app, which is one-half of your CPU's computing power, is running at 100%.

Writing software to make use of multi-core CPUs is an art unto itself. See this article for discussion. As @Alex Moore says, if you see 51% or 52%, it probably means that the other core is doing something at 1%-2%.

0

精彩评论

暂无评论...
验证码 换一张
取 消