多核CPU压力测试Visual Studio
我如何配置 Visual Studio 的测试项目以使用所有 CPU 核心。
当我运行测试时,我可以在性能指示器上看到只有一个核心正在使用(100%),其余 7 个核心未使用。
我在测试项目中有一个调用单一测试的负载测试。
我设置了 200 个用户来调用一个方法。但我需要使用所有核心。
how i can configure the Test Project of visual studio to use all CPU's core.
When i run the test i can see on my performance indicator that only one core is being used (100%) and the rest 7 cores is being unused.
I have inside the Test Project a Load Test that is calling a UNitary Test.
I had set 200 users to call a single method. But i need to use all Cores.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Dennis,根据 MSDN:
“添加 Visual Studio 负载测试虚拟非测试控制器场景中的 User Pack 2010 具有解锁所有计算机处理器以供使用的额外优势如果没有 Visual Studio Load Test Virtual User Pack 2010,您的本地计算机只能使用第一个处理器添加 Visual Studio Load Test Virtual User Pack 2010 后,负载测试在运行时可以使用计算机上的所有处理器。”
因此,如果您没有用户包许可证,则无法解锁额外的核心。
Dennis, according to MSDN:
"Adding a Visual Studio Load Test Virtual User Pack 2010 in a nontest controller scenario has the added benefit of unlocking all machine processors for use. Without a Visual Studio Load Test Virtual User Pack 2010, your local machine can use only the first processor. After you have added a Visual Studio Load Test Virtual User Pack 2010, load tests can use all processors on the machine when they run."
So there's no way to unlock your additional cores if you don't have the user pack license.
您的测试代码很可能都是单线程的。单元测试是按顺序运行的,因此除非每个测试中的代码是多线程的,否则它只会在一个线程中运行。
请注意,在多个线程中运行测试可能会产生不良后果,单元测试应该只测试单元,如果是多线程,那么测试应该是单线程的。
The chances are that your test code is all single-threaded. Unit Tests are run sequentially, so unless the code in each test is multi-threaded, it will only run in one thread.
Be carefull that running tests in multiple threads can have adverse consequences, unit tests should only test the unit, and if that is multi-threaded, then the test should be single-threaded.
您必须在多个线程中完成工作。试试这个:
您可以根据您拥有的核心数量增加后台工作人员的数量(此示例最大化了我的双核计算机)。您可以在运行工作程序后放置代码,然后通过更改 isRunning 的值来停止它们。
You have to do work in multiple threads. Try this:
You can increase the number of background workers depending on how many cores you have (this example maxes out my dual core computer). You can put your code after you run the workers, and then stop them by changing the value of isRunning.