Created
December 1, 2015 19:39
-
-
Save vagelim/882b68100c87e7b205ea to your computer and use it in GitHub Desktop.
CPU stress test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: lc [number_of_cpus_to_load [number_of_seconds] ] | |
lc() { | |
( | |
pids="" | |
cpus=${1:-1} | |
seconds=${2:-60} | |
echo loading $cpus CPUs for $seconds seconds | |
trap 'for p in $pids; do kill $p; done' 0 | |
for ((i=0;i<cpus;i++)); do while : ; do : ; done & pids="$pids $!"; done | |
sleep $seconds | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment