daily pastebin goal
52%
SHARE
TWEET

cputest.sh

a guest Oct 7th, 2014 225 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # trivial CPU speed tester
  4.  
  5. # usage
  6. # taskset -c PROCESSORID ./cputest.sh PROCESSID
  7. # examples:
  8. #
  9. # taskset -c 0 ./cputest.sh 0
  10. # taskset -c 4 ./cputest.sh 4
  11. #
  12. # taskset -c 0 ./cputest.sh 01
  13. # taskset -c 0 ./cputest.sh 02
  14.  
  15. trap ctrl_c INT
  16. function ctrl_c() {
  17.   #echo "Exiting..."
  18.   rm -f $TIMEFILE
  19.   exit
  20. }
  21.  
  22. MYID=$1
  23. TIMEFILE=/tmp/timeresult_$MYID
  24. REPS=100
  25. ETIME=0
  26. # floating point
  27. STROP="(2.01^2^13)"
  28. # integer version
  29. #STROP="(2^2^16)"
  30.  
  31. while true; do
  32.  ETIME="0"
  33.   for i in `seq 1 $REPS` ; do
  34.     echo $STROP | time -o $TIMEFILE -f "%e" bc >/dev/null
  35.     STR="$ETIME+`cat $TIMEFILE`"
  36.     #echo str is $STR
  37.     ETIME="`echo $STR |bc`"
  38.   done
  39.  
  40.  OPSPERSEC=`echo $REPS/$ETIME | bc`
  41.  echo proc id $MYID time $ETIME ops per sec $OPSPERSEC
  42.  
  43. done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top