Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- MODEL=`sysctl -A hw.model | sed s/hw\.model:\ //` #gets model identifier
- CORES=`sysctl -A hw.ncpu | sed s/hw\.ncpu:\ //` #gets number of CPU cores
- CORENUM="0" #counts which core we're on
- DIR=$(cd $(dirname "$0"); pwd)
- HOURCOUNTER=0
- trap control_c SIGINT #will call control_c() when SIGINT is caught
- control_c() {
- echo -e "\n\nStopping CPU stress\n"
- ENDTIME=`date -j -f "%a %b %d %T %Z %Y" "\`date\`" "+%s"`
- RUNTIME=$(($ENDTIME - $STARTTIME))
- HOURS=$((RUNTIME / 3600))
- SECONDS=$((RUNTIME % 3600))
- MINUTES=$((SECONDS / 60))
- SECONDS=$((SECONDS % 60))
- tput setaf 3
- echo "ended at `date`"
- echo " "
- tput sgr0
- tput setaf 1
- echo "We've been stressing $CORES cores for"
- echo "$HOURS Hours, $MINUTES Minutes, and $SECONDS Seconds."
- tput sgr0
- echo " "
- echo " "
- killall yes tail openssl Grapher ScreenSaverEngine #stop all the processes started
- RETURN=$? #get return code from killall in case something could not be stopped
- if [ $RETURN == 0 ]; #if killall returned clean, everything was stopped. if not, user will need to stop manually
- then
- echo -e "\nAll background processes stopped\n"
- exit 0
- else
- echo -e "\nThere was a problem stopping background processes - you should stop them yourself via the Activity Monitor\n"
- exit 1
- fi
- }
- clear #clears the screen
- pmset force sleep 0 displaysleep 0 disksleep 0 #keeps the machine from sleeping temporarily
- open -a /Applications/Utilities/Activity\ Monitor.app #open Activity Monitor
- open /Library/Application\ Support/Apple/Grapher/Examples/3D\ Examples/*
- /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background &
- sleep 10
- osascript -e 'tell application "Terminal"' -e 'activate' -e 'end tell'
- osascript -e 'tell application "Grapher"' -e 'activate' -e 'end tell'
- STARTTIME=`date -j -f "%a %b %d %T %Z %Y" "\`date\`" "+%s"`
- if [ -f /Applications/Expose.app/Contents/MacOS/Expose ]
- then
- /Applications/Expose.app/Contents/MacOS/Expose
- echo "Expose is in applications"
- fi
- if [ -f /Applications/Utilities/Expose.app/Contents/MacOS/Expose ]
- then
- /Applications/Utilities/Expose.app/Contents/MacOS/Expose
- echo "Expose is in utilities"
- fi
- echo " "
- tput setaf 3
- echo "started at `date`"
- tput sgr0
- echo " "
- echo -e "\nAttempting to peg $CORES CPU cores."
- tput setaf 1
- echo -e "\n******* When you wish to quit, come back to this window and type ctrl-c **************\n"
- tput sgr0
- while true; do #will run until ctrl-c
- while [ $CORENUM -lt $CORES ]; do #will run once for each core
- echo "Pegging Core $CORENUM"
- openssl enc -des3 -k foo -in /dev/zero -out /dev/null & tail /dev/random & yes>/dev/null & #run cpu-intensive tasks in background processes
- CORENUM=$[$CORENUM+1] #increment the core count
- done
- sleep 3600
- HOURCOUNTER=$(($HOURCOUNTER + 1))
- tput setaf 1
- echo -e "\nSuperMaxCPU has been maxing $CORES CPU cores for $HOURCOUNTER hours. Sweet.\n"
- tput sgr0
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement