Compare the output of 2 exe files for integers i=1 to 2^64

Viewed 23

I want to compare the output of two exe files yourExe1 and yourExe2 for the same input (integers i= 1, 2, .. 2^64 ). I wrote the file myTest1.sh below.

It would be possible to make the program faster?.

Thank you for your help!. JJV

myTest1.sh

i=0
echo INICIO $(date) >> out1.txt
echo nStart   $i >> out1.txt
while [ $i -le 4294967295 ]
do
    i=` expr $i + 1`
    if [ "$(./myExe1 $i)" != "$(./myExe2 $i)" ]
    then
    echo For $i we get different restuls. >>out1.txt
    fi

done
echo endNumber: $i >> out1.txt
echo $(date) >> out1.txt
1 Answers

There are a couple of things that can optimised.

i=` expr $i + 1`

can be written as i=$((i + 1))

echo For $i we get different restuls. >>out1.txt

can placed outside of the while loop as

while ...
do
...
done > out1.txt

All of these will avoid unnecessary overhead of subshells / redirections.

Related