[英]need ASP .Net Smple function, script call anything, to generate load on server on all cpu cores
need ASP.Net Simple function, script call anything, to generate load on server on all cpu cores.需要 ASP.Net Simple function,脚本调用任何东西,以在所有 cpu 内核的服务器上生成负载。 I i want to test IIS cpu limitations based on high cpu (with maximum load), that how server performs.我想测试基于高 cpu(最大负载)的 IIS cpu 限制,即服务器的性能。 but want simplest app to do it.但想要最简单的应用程序来做到这一点。
you can generate load on all CPU cores of a server by using the similar code as below.您可以使用如下类似的代码在服务器的所有 CPU 内核上生成负载。
// Get the number of CPU cores
var cpuCoreCount = Environment.ProcessorCount;
// Start a separate thread for each CPU core
for (int i = 0; i < cpuCoreCount; i++)
{
var thread = new Thread(() =>
{
// Generate load by calculating the sum
long sum = 0;
for (int j = 1; j <= 99000000; j++) //just a big number
{
sum += j;
}
});
thread.Start();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.