daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest Oct 8th, 2014 174 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 result - but note that bc uses only integers internally
  27. # this is actually an integer execution teste
  28. STROP="(2.01^2^13)"
  29.  
  30. # integer version
  31. #STROP="(2^2^16)"
  32.  
  33. while true; do
  34.  ETIME="0"
  35.   for i in `seq 1 $REPS` ; do
  36.     echo $STROP | time -o $TIMEFILE -f "%e" bc >/dev/null
  37.     STR="$ETIME+`cat $TIMEFILE`"
  38.     #echo str is $STR
  39.     ETIME="`echo $STR |bc`"
  40.   done
  41.  
  42.  OPSPERSEC=`echo $REPS/$ETIME | bc`
  43.  echo proc id $MYID time $ETIME ops per sec $OPSPERSEC
  44.  
  45. 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