LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Games (https://www.linuxquestions.org/questions/linux-games-33/)
-   -   Benchmarking UT2K3 performance (https://www.linuxquestions.org/questions/linux-games-33/benchmarking-ut2k3-performance-145368/)

Thetargos 02-12-2004 03:18 PM

[Script for]Benchmarking UT2K3 performance
 
I wrote this little script for benchmarking UT2K3 performance, enjoy!
Code:

#!/bin/bash
# Unreal Tournament 2003 batch benchmark script
#
# This scritp is made public in the hopes that
# some one may find it useful, I know I did.
# You are welcome to redistribute, edit or make any
# corrections to the present code, as long as you give
# back what you did. You are free to distribute this
# code under the terms of the GNU General Public License,
# which can be found on-line at www.gnu.org/licenses/.
#
#
# Original Author: Gian Paolo Mureddu AKA Thetargos.

function reswrite ()
{
        for i in $BENCHRESDIR/$NAME/*log
        do
        {       
                map=`awk -F? 'NR == 6 {printf("%s\t", $1)}' $i`
                min=`awk 'NR == 8 {printf("%.3f\t", $1)}' $i`
                mean=`awk 'NR == 8 {printf("%.3f\t", $3)}' $i`
                max=`awk 'NR == 8 {printf("%.3f\t", $5)}' $i`
                score=`awk 'NR == 9 {printf("%.3f", $3)}' $i`
                echo "$map$min$mean$max$score" >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
       
        }
        done
        echo >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        rm -f $BENCHRESDIR/$NAME/*log
}

function header ()
{
        echo "Benchmark Name: $NAME" > "$BENCHRESDIR/$NAME/$NAME-results.txt"
        echo "Unreal Tournament 2003" >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        echo -n "OS: " >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        uname -rsmp >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        glxinfo | grep renderer|  gawk '{print $4,$5,$6,$7,$8}' >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        echo >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        echo -n "Processor: " >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        cat /proc/cpuinfo | grep name | gawk '{print $4,$5,$6,$7}' >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        echo >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        echo -n "Speed: " >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        cat /proc/cpuinfo | grep MHz | gawk '{print $4}' >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        echo -n "Memory (Mb): " >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        free -mot | grep Mem | gawk '{print $2}' >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        echo >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
}

function flyprnt ()
{
        echo "Flyby benchmarks" >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        echo >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        echo "map                min        mean        max        score" >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
}


function botprnt ()
{
        echo >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        echo "Botmatch benchmarks" >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        echo >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
        echo "map                min        mean        max        score" >> "$BENCHRESDIR/$NAME/$NAME-results.txt"
}

# Defining the default path for Unreal Tournament installation.
DEFPATH="/usr/local/games/ut2003"

# Stablish the possible drivers to look for
ATi="fglrx"
NVIDIA="nvidia"

echo "#####################################################"
echo "# This program will test you computer graphic capa- #"
echo "# city based on the rendering engine and benchmarks #"
echo "# from the Unreal Tournament 2003 for Linux game.  #"
echo "#####################################################"
echo
echo
echo "Performing a series of tests..."

# Test to see whether we are using an nvidia or ATi card with their closed source drivers.
echo "Looking for the NVIDIA driver..."
echo
DRIVER=`/sbin/lsmod | grep $NVIDIA | awk '{print $1}'`
if [ "$DRIVER" == "" ]
then
        echo "No NVIDIA driver found"
        echo
        echo "Looking for the ATi driver..."
        echo
        DRIVER=`/sbin/lsmod | grep $ATi | awk '{print $1}'`
        if [ "$DRIVER" == "" ]
        then
                echo "You are not using either NVIDIA or ATi Linux drivers!"
                echo "To ensure the best performance you should use the official drivers."
                echo "Do you want me to search for the Radeon or NVIDIA DRI drivers? (y/n)"
                read ANS
                while :
                do
                        case $ANS in
                                y|Y)
                                        echo
                                        echo "Searching for NVIDIA and ATi DRI drivers..."
                                        echo
                                        DRIVER=`/sbin/lsmod | grep nv | awk '{print $1}'`
                                        if [ "$DRIVER" == "" ]
                                        then
                                                DRIVER=`/sbin/lsmod | grep radeon | awk '{print $1}'`
                                                if [ "$DRIVER" == "" ]
                                                then
                                                        echo "I could not find an NVIDIA or ATi DRI driver"
                                                        echo "Exiting..."
                                                        exit 0
                                                fi
                                               
                                        elif [ "$DRIVER" == "nv" ]
                                        then
                                                echo "NVIDIA DRI driver found: $DRIVER"
                                                break
                                        elif [ "$DRIVER" == "radeon"
                                        then
                                                echo "ATi Radeon DRI driver found: $DRIVER"
                                                break
                                        fi
                                        ;;
                                n|N)
                                        echo "I couldn't find any suitable driver and you chose not"
                                        echo "to search for DRI drivers, exiting..."
                                        exit 1
                                        ;;
                                *)
                                        echo "Please answer either y/n or cancel this program execution"
                                        echo "with CTRL-C"
                        esac
                done
        elif [ "$DRIVER" == "$NVIDIA" ]

        then
                echo "You are using the NVIDIA driver"
                echo "Verifying that you have VSync disabled..."
       
                # Test to see if we have vsync enabled
                if [ "$__GL_SYNC_TO_VBLANK" == "" || "$__GL_SYNC_TO_VBLANK" == "0" ]
                then
                        echo "You have VSync disabled, proceding"
                elif [ "$__GL_SYNC_TO_VBLANK" > "0" ]
                then
                        echo "You do not have VSync disabled, disabling..."
                        echo
                        export __GL_SYNC_TO_VBLANK=0
                        echo "VSync disabled, proceding with benchmarks"
                # Test to see if we have FSAA enabled
                elif [ "$__GL_FSAA_MODE" != "0" ]
                then
                        echo "You are running with FSAA enabled"                       
                        while :
                        do
                        echo "Do you want to run the tests with FSAA on? (y/n)"
                        read AA
                        case $AA in
                                y|Y)
                                        echo
                                        echo "Running with FSAA mode $__GL_FSAA_MODE"
                                        break
                                        ;;
                                n|N)
                                        echo
                                        echo "Disabling FSAA..."
                                        export __GL_FSAA_MODE=0
                                        break
                                        ;;
                                *)
                                        echo "Please answer whether yes or no since the results"
                                        echo "will be affected by this option."
                        esac
                        done
                # Test to see if we have AF enabled
                elif [ "$__GL_DEFAULT_LOG_ANISO" != "0" ]
                then
                        echo "You have Anisotropic Filtering enabled."
                        while :
                        do
                        echo "Do you want to run the tests with FSAA on? (y/n)"
                        read AF
                        case $AF in
                                y|Y)
                                        echo
                                        echo "Running with AF mode $__GL_DEFAULT_LOG_ANISO"
                                        break
                                        ;;
                                n|N)
                                        echo
                                        echo "Disabling AF..."

                                        export __GL_DEFAULT_LOG_ANISO=0
                                        break
                                        ;;
                                *)
                                        echo "Please answer whether yes or no since the results"
                                        echo "will be affected by this option."
                        esac
                        done
                fi
        elif [ "$DRIVER" == "$ATi" ]
        then
                echo "You are using the ATi $DRIVER driver."
                echo "As I have no way to test for VSync or FSAA with these drivers"
                echo "it is advisable for you to disable it before running this"
                echo "program. Just press CTRL-C to abort execution and"
                echo "procede to disabling VSync by running fglrxconfig"
        fi
fi

echo
echo "Looking for an Unreal Tournament 2003 installation"
echo "at the default location $DEFPATH"

while :
do
        if [ ! -d "$DEFPATH" ]
        then
                echo
                echo "The installation directory of UT2003 could not be found"
                echo "Please enter the path to your UT2003 install directory"
                read DEFPATH
        elif [ ! -x "$DEFPATH"  ]
        then
                echo
                echo "The installation directory is not executlable by $USER"
                echo "Please change the permissons or log in as another user"
                echo "Exiting..."
                exit 1
        elif [ ! -x "$DEFPATH/Benchmark/" ]
        then
                echo
                echo "The benchmark scripts are not executable by $USER"
                echo "Please change the permissons or log in as another user"
                echo "Exiting..."
                exit 2
        else
                break
        fi
done

cd "$DEFPATH/Benchmark"
NAME=$1
while [ "$NAME" == "" ]
do
        echo "You must specify a name for the benchmark"
        echo "Usage $0 <benchmark name>"
        unset NAME
        echo
        echo "Please enter the name for this benchmark"
        read NAME
done

BENCHRESDIR="$HOME/.ut2003/Benchmark/Results"

# Create benchmark name directory to store benchmark results
if [ ! -d "$BENCHRESDIR/$NAME" ]
then
        echo
        echo "Creating the directory to which the results will be stored"
        mkdir $BENCHRESDIR/$NAME
        if [ ! -f "$BENCHRESDIR/$NAME/$NAME-results.txt" ]
        then
                touch "$BENCHRESDIR/$NAME/$NAME-results.txt"
        fi
fi

header

echo "Executing Flyby benchmarks..."

flyprnt

for i in flyby*.sh
do
{
        ./$i
        for j in $BENCHRESDIR/*log
        do
        {
                mv $j $BENCHRESDIR/$NAME
        }
        done
}
done

reswrite

unset i
unset j

echo "Executing Botmatch tests"

botprnt

for i in botmatch*.sh
do
{
        ./$i -nosound
        for j in $BENCHRESDIR/*log
        do
        {
                mv $j $BENCHRESDIR/$NAME
        }
        done
}
done

reswrite

unset i
unset j

echo "Storing benchmark results..."

cd "$BENCHRESDIR/$NAME"

echo "Results stored in $BENCHRESDIR/$NAME/$NAME-results.txt"

echo
echo "Would you like to open the results?"
read ANS0

case $ANS0 in
        y|Y)
                echo "Which program would you like to use to open the files?"
                echo
                echo "1) gedit                2) kedit"
                echo
                echo "default: gedit"
                read ANS1
                case $ANS1 in
                        1)
                                gedit *txt
                                ;;
                        2)
                                kedit *txt
                                ;;
                        *)
                                gedit *txt
                esac
                ;;
        n|N)
                echo "You selected not to open the files, exiting"
                exit 2
                ;;
        *)
                echo "You did not select either y/n, exiting."
                echo "To view the files just open them in your favourite text editor"
                exit 3
esac

Just copy/paste the code, and save it as text file, then change the permisons on the file
[code]
chmod +x <filename>
[/code
And place it under your ~/bin directory to call it directly :D

EDIT: Results stored into ~/.ut2003/Benchmark/Results/<benchmarkname>/<benchmarkname>.txt


All times are GMT -5. The time now is 03:22 PM.