|
Answer» I need to load my CPU 100% ( or a variable %age) through a batch file. How do I do so?
Regards, MaheshIs this CPU a single Core or Multi-core CPU? I might be wrong, but I'm pretty sure that batch executes single threaded which would be a problem for pure batch to perform this on any COMPUTER that is a 2,3,4,6, or 8 core or more etc. Only one of the cores would peg to 100%.
Additionally I can see this being used to upset someone being able to walk up to their computer and code it up direct in notepad and save as a .bat file and run it and hide the command shell window to a far corner of the computer screen to lag out their system on them.
With all the already available stress testers like SuperPI and Y-Cruncher there is no real need to make your own... that is.... unless you want to play a trick on someone and lag out their system on them that I can see.Further thought on this you might be able to manually select core affinity for individual command shell windows to get past the single thread problem of batch in command shell. But this wouldnt be able to be automatic in batch unless there is software out there that can set core affinity within the batched instruction to assign that specific command shell to a specific core where Core 0 is the first core and Core 3 is the 4th core of a quadcore system. You would then need a menu system to have user select how many cores there are and then a batch that performs a START instruction for each core setting affinity to that shell to specific core for it to stress.I can get my i7 4790 quad core to load to 98% using one batch file. It won't go any higher. It just does arithmetic in a loop (two million divides of one number by another) and you can call it from the command line using FOR /L and START to get varying numbers of concurrent instances. One instance gets the CPU up to around 15%, and takes around 30 seconds, and the CPU maxes out at 8 concurrent copies running. The CPU has hyperthreading (8 virtual cores). You can use Process Explorer cpu usage graph to see loading and core use. One instance uses 1 virtual core and as you stack up the concurrent runs more and more cores are used until with 8 tasks all cores are loaded. The cpu idles at around 40 C but while 8 are running it goes up to 65 C. I am not going to show the code here because I would have thought that anyone who truly needs a batch solution for this would be able to write it for themselves (it took me about 2 mins) and I think it could be quite a damaging prank if a CPU was not well cooled. This is not to upset any one. Nor do some kind of mischief. Thanks for all your replies. Just to clarify: I needed this information to stress the environment and see how my application behaves in such STRESSED environment.
Regards, MaheshLots of freeware apps out there to do this as well.Quote One instance gets the CPU up to around 15%, and takes around 30 seconds, and the CPU maxes out at 8 concurrent copies running. Interesting.... i would have thought that core affinity would have had to be set to force the additional single threads to specific cores so that you dont end up with 2 SHARING a core of 8 and one of them not weighted down heavily with concurrent copies. Learned something new. Thanks for sharing that salmonQuote Learned something new Me too. I really did not expect this. I also thought I would need to force core sharing. I am running Windows 10 64-bit and I don't have any other OS to compare it with. I suppose the OS is somehow making efficient use of the CPU cores? When i TRIED it with 16 instances it looked the same as with 8, and the CPU core temp (average) went up to 75 C.
Copies running: 1
Copies running: 2
Copes running: 4
Copies running: 8
|