Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # trivial CPU speed tester
- # usage
- # taskset -c PROCESSORID ./cputest.sh PROCESSID
- # examples:
- #
- # taskset -c 0 ./cputest.sh 0
- # taskset -c 4 ./cputest.sh 4
- #
- # taskset -c 0 ./cputest.sh 01
- # taskset -c 0 ./cputest.sh 02
- trap ctrl_c INT
- function ctrl_c() {
- #echo "Exiting..."
- rm -f $TIMEFILE
- exit
- }
- MYID=$1
- TIMEFILE=/tmp/timeresult_$MYID
- REPS=100
- ETIME=0
- # floating point result - but note that bc uses only integers internally
- # this is actually an integer execution teste
- STROP="(2.01^2^13)"
- # integer version
- #STROP="(2^2^16)"
- while true; do
- ETIME="0"
- for i in `seq 1 $REPS` ; do
- echo $STROP | time -o $TIMEFILE -f "%e" bc >/dev/null
- STR="$ETIME+`cat $TIMEFILE`"
- #echo str is $STR
- ETIME="`echo $STR |bc`"
- done
- OPSPERSEC=`echo $REPS/$ETIME | bc`
- echo proc id $MYID time $ETIME ops per sec $OPSPERSEC
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement