Skip to content

Instantly share code, notes, and snippets.

@M4GNV5
Created February 10, 2018 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save M4GNV5/dbad0a612349d65b9f7140199de270d1 to your computer and use it in GitHub Desktop.
Save M4GNV5/dbad0a612349d65b9f7140199de270d1 to your computer and use it in GitHub Desktop.
Brainfuck compiler comparasion script
#!/bin/bash
set -e
input="../$1"
stdin="$2"
function measure()
{
total=0
for i in $(seq 0 9); do
start="1$(date +%s%N)"
echo "$stdin" | ./target 2>&1 > /dev/null
end="1$(date +%s%N)"
duration=$(echo "$end - $start" | bc)
#echo "Iteration $i took $duration ns"
let total=total+duration
done
let average=total/10
let averageMs=total/10000000
echo "$averageMs"
#echo "Average duration: $averageMs ms | $average ns"
}
#derp
cd code
cd ../bfdb
gcc -O0 tmp.c -o target
echo -ne "bfdb-O0 "
measure
gcc -O2 tmp.c -o target
echo -ne "bfdb-O2 "
measure
cd ../bf2c
cat $input | ./bf2c > tmp.c
gcc -O0 tmp.c -o target
echo -ne "bf2c-O0 "
measure
gcc -O2 tmp.c -o target
echo -ne "bf2c-O2 "
measure
cd ../bfc
rtarget/release/bfc -O 2 --llvm-opt 3 ../code/mandelbrot.bf
mv mandelbrot target
echo -ne "bfc "
measure
cd ../esotope-bfc
./esotope-bfc $input > tmp.c
gcc -Wno-int-to-pointer-cast -O0 tmp.c -o target
echo -ne "esotope-O0 "
measure
gcc -Wno-int-to-pointer-cast -O2 tmp.c -o target
echo -ne "esotope-O2 "
measure
cd ../Geschwindigkeitsficken
bin/speedfuck -i $input -o target
echo -ne "speedfuck "
measure
bin/speedfuck -i $input -o tmp.c
gcc -O0 tmp.c -o target
echo -ne "speedfuck-O0 "
measure
gcc -O2 tmp.c -o target
echo -ne "speedfuck-O2 "
measure
cd ../bfoptimization
python optimizr.py all < $input > tmp.c
gcc -Wno-int-to-pointer-cast -O0 tmp.c -o target
echo -ne "matslina-O0 "
measure
gcc -Wno-int-to-pointer-cast -O2 tmp.c -o target
echo -ne "matslina-O2 "
measure
cd ../yabfc
./yabfc -o target $input > /dev/null
echo -ne "yabfc "
measure
set terminal png size 1200 10
set output "comparasion.png"
set title "Mandelbrot"
set auto x
set auto y
set style data histogram
set style histogram cluster gap 1
set style fill solid 1.0 noborder
set grid back ls 102
set yrange [0:]
set ytic rotate by -45 scale 0
set boxwidth 0.9
set ylabel "Time (ms)"
plot 'comparasion.dat' using 2:xticlabels(1) notitle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment