Advertisement
Guest User

dongs

a guest
Oct 31st, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. MODEL=`sysctl -A hw.model | sed s/hw\.model:\ //` #gets model identifier
  4. CORES=`sysctl -A hw.ncpu | sed s/hw\.ncpu:\ //` #gets number of CPU cores
  5. CORENUM="0" #counts which core we're on
  6. DIR=$(cd $(dirname "$0"); pwd)
  7. HOURCOUNTER=0
  8.  
  9. trap control_c SIGINT #will call control_c() when SIGINT is caught
  10.  
  11. control_c() {
  12. echo -e "\n\nStopping CPU stress\n"
  13. ENDTIME=`date -j -f "%a %b %d %T %Z %Y" "\`date\`" "+%s"`
  14. RUNTIME=$(($ENDTIME - $STARTTIME))
  15. HOURS=$((RUNTIME / 3600))
  16. SECONDS=$((RUNTIME % 3600))
  17. MINUTES=$((SECONDS / 60))
  18. SECONDS=$((SECONDS % 60))
  19. tput setaf 3
  20. echo "ended at `date`"
  21. echo " "
  22. tput sgr0
  23. tput setaf 1
  24. echo "We've been stressing $CORES cores for"
  25. echo "$HOURS Hours, $MINUTES Minutes, and $SECONDS Seconds."
  26. tput sgr0
  27. echo " "
  28. echo " "
  29. killall yes tail openssl Grapher ScreenSaverEngine #stop all the processes started
  30. RETURN=$? #get return code from killall in case something could not be stopped
  31. if [ $RETURN == 0 ]; #if killall returned clean, everything was stopped. if not, user will need to stop manually
  32. then
  33. echo -e "\nAll background processes stopped\n"
  34. exit 0
  35. else
  36. echo -e "\nThere was a problem stopping background processes - you should stop them yourself via the Activity Monitor\n"
  37. exit 1
  38. fi
  39. }
  40.  
  41. clear #clears the screen
  42. pmset force sleep 0 displaysleep 0 disksleep 0 #keeps the machine from sleeping temporarily
  43. open -a /Applications/Utilities/Activity\ Monitor.app #open Activity Monitor
  44. open /Library/Application\ Support/Apple/Grapher/Examples/3D\ Examples/*
  45. /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background &
  46. sleep 10
  47. osascript -e 'tell application "Terminal"' -e 'activate' -e 'end tell'
  48. osascript -e 'tell application "Grapher"' -e 'activate' -e 'end tell'
  49. STARTTIME=`date -j -f "%a %b %d %T %Z %Y" "\`date\`" "+%s"`
  50. if [ -f /Applications/Expose.app/Contents/MacOS/Expose ]
  51. then
  52. /Applications/Expose.app/Contents/MacOS/Expose
  53. echo "Expose is in applications"
  54. fi
  55. if [ -f /Applications/Utilities/Expose.app/Contents/MacOS/Expose ]
  56. then
  57. /Applications/Utilities/Expose.app/Contents/MacOS/Expose
  58. echo "Expose is in utilities"
  59. fi
  60. echo " "
  61. tput setaf 3
  62. echo "started at `date`"
  63. tput sgr0
  64. echo " "
  65. echo -e "\nAttempting to peg $CORES CPU cores."
  66. tput setaf 1
  67. echo -e "\n******* When you wish to quit, come back to this window and type ctrl-c **************\n"
  68. tput sgr0
  69.  
  70. while true; do #will run until ctrl-c
  71.  
  72. while [ $CORENUM -lt $CORES ]; do #will run once for each core
  73. echo "Pegging Core $CORENUM"
  74. openssl enc -des3 -k foo -in /dev/zero -out /dev/null & tail /dev/random & yes>/dev/null & #run cpu-intensive tasks in background processes
  75. CORENUM=$[$CORENUM+1] #increment the core count
  76. done
  77. sleep 3600
  78. HOURCOUNTER=$(($HOURCOUNTER + 1))
  79. tput setaf 1
  80. echo -e "\nSuperMaxCPU has been maxing $CORES CPU cores for $HOURCOUNTER hours. Sweet.\n"
  81. tput sgr0
  82. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement