Advertisement
Guest User

cputest.sh

a guest
Oct 7th, 2014
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.78 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement