So, here is the PowerShell script (one line) that will max out your CPU:
while ($true) {$n++;$n=0}I'm not sure that the $n=0 is required, but I'm concerned that it will go past the limit of the integer variable type if it runs for an extended period of time.
Also note that this maxes out only a single CPU core because PowerShell is a single process running on a single core. In our virtual machines for courses, this is fine because each virtual machine has only a single virtual CPU.
If you need to max out multiple CPU cores then you probably need to open multiple instances of PowerShell and run the script in each one.
Hi, How can i simulate 100% CPU Usage in a 4 core processor?
ReplyDeleteIt seems this small piece of code generates max 25% of the CPU Usage. I need to use all cores and gain 100% CPU Usage.
As mentioned in the last line, you'll probably need to open multiple powershell prompts and run the script at each prompt. Then each instance of the script should max out a single core.
ReplyDeleteTOPKEK
ReplyDelete