Parcourir la source

timing script, better dependencies in Makefile, REDRUM output stream coloring preprocessor macros

Former-commit-id: 28407cd00f4bd00ea167291294aff685f792b451
Alec Jacobson (jalec il y a 12 ans
Parent
commit
259cfa6aca
3 fichiers modifiés avec 39 ajouts et 3 suppressions
  1. 3 3
      Makefile
  2. 27 0
      include/igl/REDRUM.h
  3. 9 0
      scripts/time.sh

+ 3 - 3
Makefile

@@ -40,9 +40,9 @@ endif
 .PHONY: extras
 debug: lib
 lib: obj lib/libigl.a
-examples:
+examples: lib
 	make -C examples
-extras:
+extras: extras
 	for p in  $(EXTRA_DIRS); \
 	do \
 	echo "cd $$p" ; \
@@ -86,7 +86,7 @@ lib/libigl.a: $(OBJ_FILES)
 	rm -f $@
 	ar cqs $@ $(OBJ_FILES)
 
-obj/%.o: include/igl/%.cpp include/igl/%.h
+obj/%.o: include/igl/%.cpp include/igl/%.h obj
 	$(GG) $(CFLAGS) $(AFLAGS) -c -o $@ $< $(INC)
 
 clean:

+ 27 - 0
include/igl/REDRUM.h

@@ -0,0 +1,27 @@
+#ifndef IGL_REDRUM_H
+#define IGL_REDRUM_H
+
+// Q: These should probably be inside the igl namespace. What's the correct
+// way to do that?
+// A: I guess the right way is to not use a macro but a proper function with
+// streams as input and output.
+
+// ANSI color codes for formating iostream style output
+
+// Bold Red, etc.
+#define REDRUM(X)      "\e[1m\e[31m"<<X<<"\e[m"
+#define GREENRUM(X)    "\e[1m\e[32m"<<X<<"\e[m"
+#define YELLOWRUM(X)   "\e[1m\e[33m"<<X<<"\e[m"
+#define BLUERUM(X)     "\e[1m\e[34m"<<X<<"\e[m"
+#define MAGENTARUM(X)  "\e[1m\e[35m"<<X<<"\e[m"
+#define CYANRUM(X)     "\e[1m\e[36m"<<X<<"\e[m"
+
+// Regular Red, etc.
+#define REDGIN(X)      "\e[31m"<<X<<"\e[m"
+#define GREENGIN(X)    "\e[32m"<<X<<"\e[m"
+#define YELLOWGIN(X)   "\e[33m"<<X<<"\e[m"
+#define BLUEGIN(X)     "\e[34m"<<X<<"\e[m"
+#define MAGENTAGIN(X)  "\e[35m"<<X<<"\e[m"
+#define CYANGIN(X)     "\e[36m"<<X<<"\e[m"
+
+#endif 

+ 9 - 0
scripts/time.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+
+for i in {1..20}
+do
+  make clean &>/dev/null
+  printf "$i  "
+  t=`(time make -j$i lib&>/dev/null) 2>&1 | grep real | sed -e "s/real[^0-9]*//g"`
+  echo "$t"
+done