Como você não especificou o seu sistema operacional, vou colocar aqui uma opção para o Windows e outra para o Linux:
Para Linux:
Use o Stress :
stress is a deliberately simple workload generator for POSIX systems.
It imposes a configurable amount of CPU, memory, I/O, and disk stress
on the system. It is written in C, and is free software licensed under
the GPLv2.
Here is an example invocation: a load average of four is imposed on
the system by specifying two CPU-bound processes, one I/O-bound
process, and one memory allocator process.
$ stress --cpu 2 --io 1 --vm 1 --vm-bytes 128M --timeout 10s --verbose
stress: info: [9372] dispatching hogs: 2 cpu, 1 io, 1 vm, 0 hdd
stress: dbug: [9372] (243) using backoff sleep of 12000us
stress: dbug: [9372] (262) setting timeout to 10s
stress: dbug: [9372] (285) --> hogcpu worker 9373 forked
stress: dbug: [9372] (305) --> hogio worker 9374 forked
stress: dbug: [9372] (325) --> hogvm worker 9375 forked
stress: dbug: [9372] (243) using backoff sleep of 3000us
stress: dbug: [9372] (262) setting timeout to 10s
stress: dbug: [9372] (285) --> hogcpu worker 9376 forked
stress: dbug: [9375] (466) hogvm worker malloced 134217728 bytes
stress: dbug: [9372] (382) <-- worker 9374 signalled normally
stress: dbug: [9372] (382) <-- worker 9373 signalled normally
stress: dbug: [9372] (382) <-- worker 9375 signalled normally
stress: dbug: [9372] (382) <-- worker 9376 signalled normally
stress: info: [9372] successful run completed in 10s
No Windows:
Use BES - Codificador de Batalha Shirase 1.4.5 / 1.5.2 :
Free software that controls per-process CPU usage. “Active” software
CPU cooler. BES is a small tool that throttles the CPU usage for the
process you “target”: for instance, you can limit the CPU usage of a
process which would use CPU 100%, down to 50% (or any percentage you’d
like). With this, you can use other programs comfortably while doing
something CPU-intensive in the background.
By limiting the CPU load, you can also cool down your CPU immediately
when it happens to get too hot. It’s an “active” software CPU cooler.
Conventional soft-coolers save CPU energy by making CPU sleep when it
is idle. They passively wait until CPU gets idle. BES is more
aggressive: it cools CPU by making the “heating” process slow down,
i.e. periodically forcing CPU to be idle for a short time. (But you
should install a better hardware cooler if you often need to use BES
for this purpose. Actually, the first thing you should try is to
remove dust around your heat sink (See below). Active soft-cooling
might be an interesting hack, but it's just a workaround after all. On
the other hand, if your application uses CPU 100% meaninglessly, let
BES do the job!)
Vocêtambémpodeautomatizá-lousandoalinhadecomandodoWindows:
ThefollowingcommandlinetellsBEStowatchtarget.exe,and—whentarget.exestartsrunning—throttleitsCPUusagesothattarget.exewillbeonlyallowedtouseCPU(100−percentage)%atmost:
"C:\path\to\bes.exe" "D:\path to\target.exe" [percentage] [--minimize]
Optionally, you can use an integer between 1 and 99 as percentage. If
percentage is omitted or invalid, the last known valid percentage for
target.exe is automatically used (if this is the first time to target
target.exe, the default reduction 33% will be applied, unless
percentage is specified). Note that, when started from command line,
BES will Watch/Limit the target, not just Limit it.