Explorar o código

Small tweaks and cleanup

Taddeus Kroes %!s(int64=11) %!d(string=hai) anos
pai
achega
c86205d170
Modificáronse 2 ficheiros con 10 adicións e 12 borrados
  1. 1 2
      bf.ml
  2. 9 10
      compare.sh

+ 1 - 2
bf.ml

@@ -183,8 +183,7 @@ let compile_c memsize program =
   "#include <stdio.h>\n" ^
   "#include <stdlib.h>\n" ^
   "void _start() {\n" ^
-  "    unsigned char mem[" ^ string_of_int memsize ^ "] = {};\n" ^
-  "    unsigned char *p = mem;\n" ^
+  "    unsigned char mem[" ^ string_of_int memsize ^ "] = {}, *p = mem;\n" ^
        indent (compile_commands "" program) ^
   "    exit(0);\n" ^
   "}\n"

+ 9 - 10
compare.sh

@@ -10,19 +10,18 @@ fi
 mytime () {
     (`which time` -f %e $1 > /dev/null) 2>&1
 }
-set -e
 
-echo -n "compiling opt..."
-make -s $basename-opt
-echo done
+compile () {
+    echo -n "compiling $1... "
+    t=`mytime "make -s $basename-$1"`
+    echo "took $t seconds"
+}
 
-echo -n "compiling c..."
-make -s $basename-c
-echo done
+set -e
 
-echo -n "compiling nayuki..."
-make -s $basename-nayuki
-echo done
+compile opt
+compile c
+compile nayuki
 
 echo "opt:    `mytime ./$basename-opt`"
 echo "c:      `mytime ./$basename-c`"