-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun
More file actions
executable file
·61 lines (50 loc) · 1.71 KB
/
Copy pathrun
File metadata and controls
executable file
·61 lines (50 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
states='2'
symmetry='none'
while getopts HCx:i:c:s: option; do
case $option in
H) runhs='true';;
C) runc='true';;
x) size=$OPTARG;;
i) tilesize=$OPTARG; runimages='true';;
c) states=$OPTARG;;
s) symmetry=$OPTARG;;
esac
done
runname=${size}x${size}_${states}
if [ $symmetry != none ]; then runname+=_${symmetry}; fi
echo
echo
echo $runname
mkdir -p bin
mkdir -p results/$runname
if [ "$runc" ]; then
clang tiles.c -O2 -flto -o bin/${runname}_c -DSIZE=$size -DSTATES=$states -D$symmetry
echo Running C...
time ./bin/${runname}_c > results/$runname/results_c
resultsfile="results/$runname/results_c"
fi
if [ "$runhs" ]; then
ghc tiles.hs -v0 -O2 -o bin/${runname}_hs -cpp -DSIZE=$size -DSTATES=$states -D$symmetry
echo Running Haskell...
time ./bin/${runname}_hs > results/$runname/results_hs
resultsfile="results/$runname/results_hs"
fi
if [ "$runc" -a "$runhs" ]; then
diff results/$runname/results_c results/$runname/results_hs -q
fi
cp $resultsfile results/$runname/results
if [ "$runimages" ]; then
echo Rendering images...
time (cat results/$runname/results | while read count tile; do
echo P2 $size $size $((states-1)) $(echo $tile | sed 's/./& /g') | pnmtile $tilesize $tilesize > "results/$runname/$tile.pgm"
optipng -o7 -strip all -fix -quiet results/$runname/$tile.pgm
zopflipng results/$runname/$tile.png results/$runname/$tile.png -y > /dev/null
rm results/$runname/$tile.pgm
done)
title="${size}x${size} "
if [ $states != 2 ]; then title+="${states}-state "; fi
if [ $symmetry != none ]; then title+="$symmetry "; fi
title+="patterns"
cat results/$runname/results | sort -k 2 -r | sort -k 1,1 -n -s | ./makehtml.py "$title" $((tilesize*2)) > results/$runname/index.html
fi