Workig perftest and cairo build
authorBenoit Girard <b56girard@gmail.com>
Tue, 07 May 2013 18:28:52 -0400
changeset 5 32cc80c5fdba9a9d2612fbbaea8eddc0b3b23a2a
parent 4 0f43ac82cf19a420848d872fa0c388adb46684b4
child 6 fbb91259ab8d5c1f057c8c002e3bc69d18de29c2
push id5
push userb56girard@gmail.com
push dateTue, 07 May 2013 22:28:59 +0000
Workig perftest and cairo build
Makefile.cairo
Makefile.d2d
Makefile.standalone
perftest/TestBase.h
--- a/Makefile.cairo
+++ b/Makefile.cairo
@@ -9,8 +9,12 @@ LIBS += `pkg-config --libs cairo`
 DEFINES  += USE_CAIRO
 
 MOZ2D_CPPSRCS += \
   DrawTargetCairo.cpp \
   PathCairo.cpp \
   SourceSurfaceCairo.cpp \
   $(NULL)
 
+TESTING_CPPSRCS += \
+  perftest/TestDrawTargetCairoImage.cpp \
+  $(NULL)
+
--- a/Makefile.d2d
+++ b/Makefile.d2d
@@ -1,12 +1,12 @@
 
 # TODO FontWin belong here?
 
-MOZ2D_CPPSRCS +=
+MOZ2D_CPPSRCS += \
   DrawTargetD2D.cpp \
   PathD2D.cpp \
   SourceSurfaceD2D.cpp \
   SourceSurfaceD2DTarget.cpp \
   ScaledFontDWrite.cpp \
   ScaledFontWin.cpp \
   $(NULL)
 
--- a/Makefile.standalone
+++ b/Makefile.standalone
@@ -1,15 +1,15 @@
 # High level targets
 .PHONY: release debug clean
 
 OBJDIR_RELEASE=release
 OBJDIR_DEBUG=debug
 INCLUDES=.
-CXXFLAGS=$(addprefix -I,$(INCLUDES)) -std=gnu++0x
+CXXFLAGS=-g $(addprefix -I,$(INCLUDES)) -std=gnu++0x
 DEFINES=
 
 # TODO: Files that depends on mozilla:
 #./gfx/thebes/gfxFont.h
 #convolver.cpp
 #image_operations.cpp
 
 MOZ2D_CPPSRCS_ALLPLATFORMS = \
@@ -28,75 +28,90 @@ MOZ2D_CPPSRCS_ALLPLATFORMS = \
   Scale.cpp \
   ScaledFontBase.cpp \
   SourceSurfaceRawData.cpp \
   $(NULL)
 
 # TODO:
 #unittest/TestDrawTargetBase.cpp
 
-TESTING_CPPSRS_ALLPLATFORMS = \
+PERFTEST_CPPSRCS_ALLPLATFORMS = \
+  perftest/Main.cpp \
+  perftest/SanityChecks.cpp \
+  perftest/TestBase.cpp \
+  perftest/TestDrawTargetBase.cpp \
+  $(NULL)
+
+UNITTEST_CPPSRCS_ALLPLATFORMS = \
   unittest/SanityChecks.cpp \
   unittest/TestBase.cpp \
   unittest/TestPoint.cpp \
   unittest/TestScaling.cpp \
   unittest/Main.cpp \
   $(NULL)
 
 MOZ2D_CPPSRCS = $(MOZ2D_CPPSRCS_ALLPLATFORMS)
-TESTING_CPPSRS = $(TESTING_CPPSRS_ALLPLATFORMS)
+UNITTEST_CPPSRCS = $(UNITTEST_CPPSRCS_ALLPLATFORMS)
+PERFTEST_CPPSRCS = $(PERFTEST_CPPSRCS_ALLPLATFORMS)
 
 # ================ OS FEATURES ================
 UNAME = $(shell uname)
 ifeq ($(UNAME),Darwin)
 LIBS += -framework CoreFoundation
 endif
 
 # ================ INCLUDE FEATURE SPECIFIC MAKEFILES =================
 # These will modify the following variables:
-#   TESTING_CPPSRS
+#   TESTING_CPPSRCS
 #   MOZ2D_CPPSRCS
 #   DEFINES
 #
 ifdef MOZ2D_D2D
  -include Makefile.d2d
 endif
 ifdef MOZ2D_CG
  -include Makefile.cg
 endif
 ifdef MOZ2D_CAIRO
  -include Makefile.cairo
 endif
   
-CPPSRCS = $(MOZ2D_CPPSRCS) $(TESTING_CPPSRS)
+CPPSRCS = $(MOZ2D_CPPSRCS) $(TESTING_CPPSRCS) $(PERFTEST_CPPSRCS)
+PRE_PERFTEST_CPPSRCS = $(MOZ2D_CPPSRCS) $(PERFTEST_CPPSRCS)
+PRE_UNITTEST_CPPSRCS = $(MOZ2D_CPPSRCS) $(TESTING_CPPSRCS)
 
 RELEASE_CPPSRCS = $(addprefix $(OBJDIR_RELEASE)/,$(CPPSRCS))
 DEBUG_CPPSRCS = $(addprefix $(OBJDIR_DEBUG)/,$(CPPSRCS))
+RELEASE_PERFTEST_CPPSRCS = $(addprefix $(OBJDIR_RELEASE)/,$(PRE_PERFTEST_CPPSRCS))
+DEBUG_UNITTEST_CPPSRCS = $(addprefix $(OBJDIR_DEBUG)/,$(PRE_UNITTEST_CPPSRCS))
 COMPILER_DEFINES = $(addprefix -D,$(DEFINES))
 
 -include $(RELEASE_CPPSRCS:.cpp=.d)
 -include $(DEBUG_CPPSRCS:.cpp=.d)
 
-release: $(RELEASE_CPPSRCS:.cpp=.o) $(OBJDIR_RELEASE)/unittest/unittest $(OBJDIR_RELEASE)/.mkdir.done
+release: $(RELEASE_CPPSRCS:.cpp=.o) $(OBJDIR_RELEASE)/unittest/unittest $(OBJDIR_RELEASE)/perftest/perftest $(OBJDIR_RELEASE)/.mkdir.done
 
-debug: $(DEBUG_CPPSRCS:.cpp=.o) $(OBJDIR_DEBUG)/unittest/unittest $(OBJDIR_DEBUG)/.mkdir.done
+debug: $(DEBUG_CPPSRCS:.cpp=.o) $(OBJDIR_DEBUG)/unittest/unittest $(OBJDIR_DEBUG)/perftest/perftest $(OBJDIR_DEBUG)/.mkdir.done
 
 $(OBJDIR_RELEASE)/unittest/unittest: $(RELEASE_CPPSRCS:.cpp=.o)
-	echo $(UNAME)
-	$(CXX) $(LIBS) $(RELEASE_CPPSRCS:.cpp=.o) -o release/unittest/unittest
+	$(CXX) $(LIBS) $(RELEASE_CPPSRCS:.cpp=.o) -o $(OBJDIR_RELEASE)/unittest/unittest
+
+$(OBJDIR_RELEASE)/perftest/perftest: $(RELEASE_CPPSRCS:.cpp=.o)
+	$(CXX) $(LIBS) $(RELEASE_CPPSRCS:.cpp=.o) -o $(OBJDIR_RELEASE)/perftest/perftest
 
 clean:
 	rm -rf $(OBJDIR_RELEASE) $(OBJDIR_DEBUG)
 
 
 
 
 # ================== IMPLICIT RULES ===========================
 
 %/.mkdir.done:
+	mkdir -p $(dir $@)/perftest
 	mkdir -p $(dir $@)/unittest
 	mkdir -p $@
 
 $(OBJDIR_RELEASE)/%.o: %.cpp $(OBJDIR_RELEASE)/.mkdir.done
 	$(CXX) -c $(COMPILER_DEFINES) $(CXXFLAGS) -o $@ $<
 	$(CXX) -MM $(COMPILER_DEFINES) $(CXXFLAGS) -o $(@:.o=.d) $<
 
 $(OBJDIR_DEBUG)/%.o: %.cpp $(OBJDIR_DEBUG)/.mkdir.done
--- a/perftest/TestBase.h
+++ b/perftest/TestBase.h
@@ -9,48 +9,62 @@
 #include <vector>
 
 #ifdef _MSC_VER
 // On MSVC otherwise our generic member pointer trick doesn't work.
 #pragma pointers_to_members(full_generality, single_inheritance)
 #include <Windows.h>
 #else
 #include <pthread.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <unistd.h>
 #endif
 
 inline void SleepMS(int aMilliseconds)
 {
 #ifdef _MSC_VER
   ::Sleep(aMilliseconds);
 #else
-  sleep(aMilliseconds);
+  usleep(1000 * aMilliseconds);
 #endif
 }
 
 class HighPrecisionMeasurement
 {
 public:
   void Start() {
 #ifdef WIN32
     ::QueryPerformanceCounter(&mStart);
+#else
+    gettimeofday(&mStart, NULL);
 #endif
   }
 
   double Measure() {
 #ifdef WIN32
     LARGE_INTEGER end, freq;
     ::QueryPerformanceCounter(&end);
     ::QueryPerformanceFrequency(&freq);
     return (double(end.QuadPart) - double(mStart.QuadPart)) / double(freq.QuadPart) * 1000.00;
+#else
+    struct timeval end;
+    gettimeofday(&end, NULL);
+
+    long seconds = end.tv_sec - mStart.tv_sec;
+    long useconds = end.tv_usec - mStart.tv_usec;
+    long mtime = ((seconds) * 1000 + useconds/1000.0) + 0.5;
+    return mtime;
 #endif
-    return 0;
   }
 private:
 #ifdef WIN32
   LARGE_INTEGER mStart;
+#else
+  struct timeval mStart;
 #endif
 };
 
 #define REGISTER_TEST(className, testName) \
   mTests.push_back(Test(static_cast<TestCall>(&className::testName), #testName, this))
 
 class TestBase
 {