Pārlūkot izejas kodu

Profile build with profiler

Kajetan Johannes Hammerle 2 nedēļas atpakaļ
vecāks
revīzija
dad480c2e3
3 mainītis faili ar 20 papildinājumiem un 4 dzēšanām
  1. 1 0
      .gitignore
  2. 8 0
      include/core/Check.h
  3. 11 4
      tasks

+ 1 - 0
.gitignore

@@ -1,4 +1,5 @@
 build_debug
+build_profile
 build_release
 install
 profile

+ 8 - 0
include/core/Check.h

@@ -16,6 +16,14 @@
 #error "please add a 'check_format' option"
 #endif
 
+#if defined(__GNUC__)
+#define likely(x) __builtin_expect(!!(x), 1)
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#else
+#define likely(x) x
+#define unlikely(x) x
+#endif
+
 #define cbool check_return bool
 
 #endif

+ 11 - 4
tasks

@@ -29,6 +29,7 @@ fi
 
 # task vars
 build_debug=false
+build_profile=false
 build_release=false
 
 test_debug=false
@@ -44,7 +45,7 @@ export CMAKE_EXPORT_COMPILE_COMMANDS=true
 
 # parsing
 if [ "$task" = "clean" ]; then
-    rm -rf build_debug build_release install
+    rm -rf build_debug build_profile build_release install
 elif [ "$task" = "build" ]; then
     type=$2
     if [ "$type" = "debug" ]; then
@@ -101,7 +102,7 @@ elif [ "$task" = "valgrind" ]; then
     fi
     valgrind="valgrind"
 elif [ "$task" = "performance" ]; then
-    build_release=true
+    build_profile=true
     performance=true
 elif [ "$task" = "time" ]; then
     build_release=true
@@ -127,6 +128,9 @@ buildProfile() {
 if $build_debug; then
     buildProfile build_debug -DCMAKE_BUILD_TYPE=Debug
 fi
+if $build_profile; then
+    buildProfile build_profile -DCMAKE_BUILD_TYPE=RelWithDebInfo
+fi
 if $build_release; then
     buildProfile build_release -DCMAKE_BUILD_TYPE=Release
 fi
@@ -158,8 +162,11 @@ if $test_release; then
     cd ..
 fi
 if $performance; then
-    cd build_release
-    ./performance
+    cd build_profile
+    user=$(whoami)
+    sudo perf record ./performance
+    sudo chown $user:$user perf.data
+    perf report
     cd ..
 fi
 if $time; then