简体   繁体   English

在调试模式下运行Visual Studio控制台应用程序的CPU使用率不会超过50%

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

I have a several C# console applications that basically parse tons of data in memory (LINQ) and output the results to a text file. 我有几个C#控制台应用程序,基本上解析内存中的大量数据(LINQ)并将结果输出到文本文件。

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. 当我在调试模式下运行应用程序时,我永远不会使用超过50%的CPU使用率。 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). 它将解析/按摩数十万条记录,但只能快速运行X并利用50%的CPU(在任务管理器中查看)。

I would really like to use 100% of the CPU to make the processing go faster. 我真的想用100%的CPU来加快处理速度。

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. 我正在运行带有Service Pack 3的Windows XP Professional。我安装了带Service Pack 1的Visual Studio 2008 Professional。

Thanks! 谢谢!

EDIT: 编辑:

  • I have manually set the affinity of the process in Task Manager to a single core on the dual CPU. 我已手动将任务管理器中进程的关联设置为双CPU上的单个核心。
  • Sometimes I can catch it utilizing 51% or 52% of the CPU. 有时我可以利用51%或52%的CPU来捕获它。

听起来你有一个双核CPU,你的应用程序是单线程的。

Sounds like you have a dual core cpu. 听起来你有一个双核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. 此外,您看到的51/52%是在另一个核心上运行的其他进程,以1-2%加速您的程序在第一个核心上全速运行。

If you want to attempt to make your program use both cores, try looking into PLINQ in the Parallel Extensions library. 如果您想尝试让程序使用两个内核,请尝试在Parallel Extensions库中查看PLINQ。

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. 如果您的应用程序仅在一个线程上执行,而您碰巧有双核处理器,则只使用其中一个核心,因此您使用50%的可用处理器能力。

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%. 它利用这个核心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. 正如其他人所说,您的应用程序运行在双核(2)核心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%. 当您在任务管理器中看到50%时,这意味着运行您的应用程序的核心,即CPU的计算能力的一半,正在以100%运行。

Writing software to make use of multi-core CPUs is an art unto itself. 编写软件以利用多核CPU本身就是一门艺术。 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%. 正如@Alex Moore所说,如果你看到51%或52%,这可能意味着另一个核心正在做1%-2%的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio 2015使用节点100%的CPU使用率 - Visual Studio 2015 100-percent CPU usage with Node 在Visual Studio调试模式下运行时重新启动应用程序 - Runtime restart application in visual studio debug mode Visual Studio Performance Profiling.Net Core 控制台应用程序通过对 nvlddmkm.sys 的“unwalkable”调用显示大量 CPU 使用率 - Visual Studio Performance Profiling .Net Core console application shows significant CPU usage by "unwalkable" calls into nvlddmkm.sys 如何使用 gMSA 调试作为服务运行的 Visual Studio 2022 控制台应用程序 - How to debug a Visual Studio 2022 console application running as a service using a gMSA 控制台应用程序中CPU使用率高 - High CPU usage in console application Visual Studio 2010 Pro,不会在应用程序关闭时结束调试模式 - Visual Studio 2010 Pro, not ending debug mode on application close 如何从Visual Studio 2013调试.NET控制台应用程序 - How to debug .NET console application from Visual Studio 2013 Web解决方案中的Visual Studio C#调试控制台应用程序 - Visual Studio C# debug console application that is part of web solution 如何获得超过 2 个内核的 CPU 使用率? - How to get CPU usage for more than 2 cores? WPF Visual Studio 调试 - 控制台 - WPF Visual Studio Debug - Console
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM